{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Consuming Iterators Manually"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We've already seen how to do this:\n",
    "\n",
    "* get an iterator from the iterable\n",
    "* call next on the iterator (until the `StopIteration` exception is raised)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's quickly see how do this again, using a string as the underlying iterable:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "s = 'I sleep all night, and I work all day'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "iter_s = iter(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I\n",
      " \n",
      "s\n",
      "l\n",
      "e\n"
     ]
    }
   ],
   "source": [
    "print(next(iter_s))\n",
    "print(next(iter_s))\n",
    "print(next(iter_s))\n",
    "print(next(iter_s))\n",
    "print(next(iter_s))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This means we can get the next item in a collection without actually using a loop of any kind.\n",
    "\n",
    "Why might this be useful?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Example 1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A fairly typical use case for this would be when reading data from a CSV file where you know the first few lines consist of information abotu teh data rather than just the data itself.\n",
    "\n",
    "Let's try this using a CSV file I have saved alongside the Jupyter notebook."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's first load the data and see what it looks like:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Car;MPG;Cylinders;Displacement;Horsepower;Weight;Acceleration;Model;Origin\n",
      "\n",
      "STRING;DOUBLE;INT;DOUBLE;DOUBLE;DOUBLE;DOUBLE;INT;CAT\n",
      "\n",
      "Chevrolet Chevelle Malibu;18.0;8;307.0;130.0;3504.;12.0;70;US\n",
      "\n",
      "Buick Skylark 320;15.0;8;350.0;165.0;3693.;11.5;70;US\n",
      "\n",
      "Plymouth Satellite;18.0;8;318.0;150.0;3436.;11.0;70;US\n",
      "\n",
      "AMC Rebel SST;16.0;8;304.0;150.0;3433.;12.0;70;US\n",
      "\n",
      "Ford Torino;17.0;8;302.0;140.0;3449.;10.5;70;US\n",
      "\n",
      "Ford Galaxie 500;15.0;8;429.0;198.0;4341.;10.0;70;US\n",
      "\n",
      "Chevrolet Impala;14.0;8;454.0;220.0;4354.;9.0;70;US\n",
      "\n",
      "Plymouth Fury iii;14.0;8;440.0;215.0;4312.;8.5;70;US\n",
      "\n",
      "Pontiac Catalina;14.0;8;455.0;225.0;4425.;10.0;70;US\n",
      "\n",
      "AMC Ambassador DPL;15.0;8;390.0;190.0;3850.;8.5;70;US\n",
      "\n",
      "Citroen DS-21 Pallas;0;4;133.0;115.0;3090.;17.5;70;Europe\n",
      "\n",
      "Chevrolet Chevelle Concours (sw);0;8;350.0;165.0;4142.;11.5;70;US\n",
      "\n",
      "Ford Torino (sw);0;8;351.0;153.0;4034.;11.0;70;US\n",
      "\n",
      "Plymouth Satellite (sw);0;8;383.0;175.0;4166.;10.5;70;US\n",
      "\n",
      "AMC Rebel SST (sw);0;8;360.0;175.0;3850.;11.0;70;US\n",
      "\n",
      "Dodge Challenger SE;15.0;8;383.0;170.0;3563.;10.0;70;US\n",
      "\n",
      "Plymouth 'Cuda 340;14.0;8;340.0;160.0;3609.;8.0;70;US\n",
      "\n",
      "Ford Mustang Boss 302;0;8;302.0;140.0;3353.;8.0;70;US\n",
      "\n",
      "Chevrolet Monte Carlo;15.0;8;400.0;150.0;3761.;9.5;70;US\n",
      "\n",
      "Buick Estate Wagon (sw);14.0;8;455.0;225.0;3086.;10.0;70;US\n",
      "\n",
      "Toyota Corolla Mark ii;24.0;4;113.0;95.00;2372.;15.0;70;Japan\n",
      "\n",
      "Plymouth Duster;22.0;6;198.0;95.00;2833.;15.5;70;US\n",
      "\n",
      "AMC Hornet;18.0;6;199.0;97.00;2774.;15.5;70;US\n",
      "\n",
      "Ford Maverick;21.0;6;200.0;85.00;2587.;16.0;70;US\n",
      "\n",
      "Datsun PL510;27.0;4;97.00;88.00;2130.;14.5;70;Japan\n",
      "\n",
      "Volkswagen 1131 Deluxe Sedan;26.0;4;97.00;46.00;1835.;20.5;70;Europe\n",
      "\n",
      "Peugeot 504;25.0;4;110.0;87.00;2672.;17.5;70;Europe\n",
      "\n",
      "Audi 100 LS;24.0;4;107.0;90.00;2430.;14.5;70;Europe\n",
      "\n",
      "Saab 99e;25.0;4;104.0;95.00;2375.;17.5;70;Europe\n",
      "\n",
      "BMW 2002;26.0;4;121.0;113.0;2234.;12.5;70;Europe\n",
      "\n",
      "AMC Gremlin;21.0;6;199.0;90.00;2648.;15.0;70;US\n",
      "\n",
      "Ford F250;10.0;8;360.0;215.0;4615.;14.0;70;US\n",
      "\n",
      "Chevy C20;10.0;8;307.0;200.0;4376.;15.0;70;US\n",
      "\n",
      "Dodge D200;11.0;8;318.0;210.0;4382.;13.5;70;US\n",
      "\n",
      "Hi 1200D;9.0;8;304.0;193.0;4732.;18.5;70;US\n",
      "\n",
      "Datsun PL510;27.0;4;97.00;88.00;2130.;14.5;71;Japan\n",
      "\n",
      "Chevrolet Vega 2300;28.0;4;140.0;90.00;2264.;15.5;71;US\n",
      "\n",
      "Toyota Corolla;25.0;4;113.0;95.00;2228.;14.0;71;Japan\n",
      "\n",
      "Ford Pinto;25.0;4;98.00;0;2046.;19.0;71;US\n",
      "\n",
      "Volkswagen Super Beetle 117;0;4;97.00;48.00;1978.;20.0;71;Europe\n",
      "\n",
      "AMC Gremlin;19.0;6;232.0;100.0;2634.;13.0;71;US\n",
      "\n",
      "Plymouth Satellite Custom;16.0;6;225.0;105.0;3439.;15.5;71;US\n",
      "\n",
      "Chevrolet Chevelle Malibu;17.0;6;250.0;100.0;3329.;15.5;71;US\n",
      "\n",
      "Ford Torino 500;19.0;6;250.0;88.00;3302.;15.5;71;US\n",
      "\n",
      "AMC Matador;18.0;6;232.0;100.0;3288.;15.5;71;US\n",
      "\n",
      "Chevrolet Impala;14.0;8;350.0;165.0;4209.;12.0;71;US\n",
      "\n",
      "Pontiac Catalina Brougham;14.0;8;400.0;175.0;4464.;11.5;71;US\n",
      "\n",
      "Ford Galaxie 500;14.0;8;351.0;153.0;4154.;13.5;71;US\n",
      "\n",
      "Plymouth Fury iii;14.0;8;318.0;150.0;4096.;13.0;71;US\n",
      "\n",
      "Dodge Monaco (sw);12.0;8;383.0;180.0;4955.;11.5;71;US\n",
      "\n",
      "Ford Country Squire (sw);13.0;8;400.0;170.0;4746.;12.0;71;US\n",
      "\n",
      "Pontiac Safari (sw);13.0;8;400.0;175.0;5140.;12.0;71;US\n",
      "\n",
      "AMC Hornet Sportabout (sw);18.0;6;258.0;110.0;2962.;13.5;71;US\n",
      "\n",
      "Chevrolet Vega (sw);22.0;4;140.0;72.00;2408.;19.0;71;US\n",
      "\n",
      "Pontiac Firebird;19.0;6;250.0;100.0;3282.;15.0;71;US\n",
      "\n",
      "Ford Mustang;18.0;6;250.0;88.00;3139.;14.5;71;US\n",
      "\n",
      "Mercury Capri 2000;23.0;4;122.0;86.00;2220.;14.0;71;US\n",
      "\n",
      "Opel 1900;28.0;4;116.0;90.00;2123.;14.0;71;Europe\n",
      "\n",
      "Peugeot 304;30.0;4;79.00;70.00;2074.;19.5;71;Europe\n",
      "\n",
      "Fiat 124B;30.0;4;88.00;76.00;2065.;14.5;71;Europe\n",
      "\n",
      "Toyota Corolla 1200;31.0;4;71.00;65.00;1773.;19.0;71;Japan\n",
      "\n",
      "Datsun 1200;35.0;4;72.00;69.00;1613.;18.0;71;Japan\n",
      "\n",
      "Volkswagen Model 111;27.0;4;97.00;60.00;1834.;19.0;71;Europe\n",
      "\n",
      "Plymouth Cricket;26.0;4;91.00;70.00;1955.;20.5;71;US\n",
      "\n",
      "Toyota Corolla Hardtop;24.0;4;113.0;95.00;2278.;15.5;72;Japan\n",
      "\n",
      "Dodge Colt Hardtop;25.0;4;97.50;80.00;2126.;17.0;72;US\n",
      "\n",
      "Volkswagen Type 3;23.0;4;97.00;54.00;2254.;23.5;72;Europe\n",
      "\n",
      "Chevrolet Vega;20.0;4;140.0;90.00;2408.;19.5;72;US\n",
      "\n",
      "Ford Pinto Runabout;21.0;4;122.0;86.00;2226.;16.5;72;US\n",
      "\n",
      "Chevrolet Impala;13.0;8;350.0;165.0;4274.;12.0;72;US\n",
      "\n",
      "Pontiac Catalina;14.0;8;400.0;175.0;4385.;12.0;72;US\n",
      "\n",
      "Plymouth Fury III;15.0;8;318.0;150.0;4135.;13.5;72;US\n",
      "\n",
      "Ford Galaxie 500;14.0;8;351.0;153.0;4129.;13.0;72;US\n",
      "\n",
      "AMC Ambassador SST;17.0;8;304.0;150.0;3672.;11.5;72;US\n",
      "\n",
      "Mercury Marquis;11.0;8;429.0;208.0;4633.;11.0;72;US\n",
      "\n",
      "Buick LeSabre Custom;13.0;8;350.0;155.0;4502.;13.5;72;US\n",
      "\n",
      "Oldsmobile Delta 88 Royale;12.0;8;350.0;160.0;4456.;13.5;72;US\n",
      "\n",
      "Chrysler Newport Royal;13.0;8;400.0;190.0;4422.;12.5;72;US\n",
      "\n",
      "Mazda RX2 Coupe;19.0;3;70.00;97.00;2330.;13.5;72;Japan\n",
      "\n",
      "AMC Matador (sw);15.0;8;304.0;150.0;3892.;12.5;72;US\n",
      "\n",
      "Chevrolet Chevelle Concours (sw);13.0;8;307.0;130.0;4098.;14.0;72;US\n",
      "\n",
      "Ford Gran Torino (sw);13.0;8;302.0;140.0;4294.;16.0;72;US\n",
      "\n",
      "Plymouth Satellite Custom (sw);14.0;8;318.0;150.0;4077.;14.0;72;US\n",
      "\n",
      "Volvo 145e (sw);18.0;4;121.0;112.0;2933.;14.5;72;Europe\n",
      "\n",
      "Volkswagen 411 (sw);22.0;4;121.0;76.00;2511.;18.0;72;Europe\n",
      "\n",
      "Peugeot 504 (sw);21.0;4;120.0;87.00;2979.;19.5;72;Europe\n",
      "\n",
      "Renault 12 (sw);26.0;4;96.00;69.00;2189.;18.0;72;Europe\n",
      "\n",
      "Ford Pinto (sw);22.0;4;122.0;86.00;2395.;16.0;72;US\n",
      "\n",
      "Datsun 510 (sw);28.0;4;97.00;92.00;2288.;17.0;72;Japan\n",
      "\n",
      "Toyota Corolla Mark II (sw);23.0;4;120.0;97.00;2506.;14.5;72;Japan\n",
      "\n",
      "Dodge Colt (sw);28.0;4;98.00;80.00;2164.;15.0;72;US\n",
      "\n",
      "Toyota Corolla 1600 (sw);27.0;4;97.00;88.00;2100.;16.5;72;Japan\n",
      "\n",
      "Buick Century 350;13.0;8;350.0;175.0;4100.;13.0;73;US\n",
      "\n",
      "AMC Matador;14.0;8;304.0;150.0;3672.;11.5;73;US\n",
      "\n",
      "Chevrolet Malibu;13.0;8;350.0;145.0;3988.;13.0;73;US\n",
      "\n",
      "Ford Gran Torino;14.0;8;302.0;137.0;4042.;14.5;73;US\n",
      "\n",
      "Dodge Coronet Custom;15.0;8;318.0;150.0;3777.;12.5;73;US\n",
      "\n",
      "Mercury Marquis Brougham;12.0;8;429.0;198.0;4952.;11.5;73;US\n",
      "\n",
      "Chevrolet Caprice Classic;13.0;8;400.0;150.0;4464.;12.0;73;US\n",
      "\n",
      "Ford LTD;13.0;8;351.0;158.0;4363.;13.0;73;US\n",
      "\n",
      "Plymouth Fury Gran Sedan;14.0;8;318.0;150.0;4237.;14.5;73;US\n",
      "\n",
      "Chrysler New Yorker Brougham;13.0;8;440.0;215.0;4735.;11.0;73;US\n",
      "\n",
      "Buick Electra 225 Custom;12.0;8;455.0;225.0;4951.;11.0;73;US\n",
      "\n",
      "AMC Ambassador Brougham;13.0;8;360.0;175.0;3821.;11.0;73;US\n",
      "\n",
      "Plymouth Valiant;18.0;6;225.0;105.0;3121.;16.5;73;US\n",
      "\n",
      "Chevrolet Nova Custom;16.0;6;250.0;100.0;3278.;18.0;73;US\n",
      "\n",
      "AMC Hornet;18.0;6;232.0;100.0;2945.;16.0;73;US\n",
      "\n",
      "Ford Maverick;18.0;6;250.0;88.00;3021.;16.5;73;US\n",
      "\n",
      "Plymouth Duster;23.0;6;198.0;95.00;2904.;16.0;73;US\n",
      "\n",
      "Volkswagen Super Beetle;26.0;4;97.00;46.00;1950.;21.0;73;Europe\n",
      "\n",
      "Chevrolet Impala;11.0;8;400.0;150.0;4997.;14.0;73;US\n",
      "\n",
      "Ford Country;12.0;8;400.0;167.0;4906.;12.5;73;US\n",
      "\n",
      "Plymouth Custom Suburb;13.0;8;360.0;170.0;4654.;13.0;73;US\n",
      "\n",
      "Oldsmobile Vista Cruiser;12.0;8;350.0;180.0;4499.;12.5;73;US\n",
      "\n",
      "AMC Gremlin;18.0;6;232.0;100.0;2789.;15.0;73;US\n",
      "\n",
      "Toyota Camry;20.0;4;97.00;88.00;2279.;19.0;73;Japan\n",
      "\n",
      "Chevrolet Vega;21.0;4;140.0;72.00;2401.;19.5;73;US\n",
      "\n",
      "Datsun 610;22.0;4;108.0;94.00;2379.;16.5;73;Japan\n",
      "\n",
      "Mazda RX3;18.0;3;70.00;90.00;2124.;13.5;73;Japan\n",
      "\n",
      "Ford Pinto;19.0;4;122.0;85.00;2310.;18.5;73;US\n",
      "\n",
      "Mercury Capri v6;21.0;6;155.0;107.0;2472.;14.0;73;US\n",
      "\n",
      "Fiat 124 Sport Coupe;26.0;4;98.00;90.00;2265.;15.5;73;Europe\n",
      "\n",
      "Chevrolet Monte Carlo S;15.0;8;350.0;145.0;4082.;13.0;73;US\n",
      "\n",
      "Pontiac Grand Prix;16.0;8;400.0;230.0;4278.;9.50;73;US\n",
      "\n",
      "Fiat 128;29.0;4;68.00;49.00;1867.;19.5;73;Europe\n",
      "\n",
      "Opel Manta;24.0;4;116.0;75.00;2158.;15.5;73;Europe\n",
      "\n",
      "Audi 100LS;20.0;4;114.0;91.00;2582.;14.0;73;Europe\n",
      "\n",
      "Volvo 144ea;19.0;4;121.0;112.0;2868.;15.5;73;Europe\n",
      "\n",
      "Dodge Dart Custom;15.0;8;318.0;150.0;3399.;11.0;73;US\n",
      "\n",
      "Saab 99le;24.0;4;121.0;110.0;2660.;14.0;73;Europe\n",
      "\n",
      "Toyota Mark II;20.0;6;156.0;122.0;2807.;13.5;73;Japan\n",
      "\n",
      "Oldsmobile Omega;11.0;8;350.0;180.0;3664.;11.0;73;US\n",
      "\n",
      "Plymouth Duster;20.0;6;198.0;95.00;3102.;16.5;74;US\n",
      "\n",
      "Ford Maverick;21.0;6;200.0;0;2875.;17.0;74;US\n",
      "\n",
      "AMC Hornet;19.0;6;232.0;100.0;2901.;16.0;74;US\n",
      "\n",
      "Chevrolet Nova;15.0;6;250.0;100.0;3336.;17.0;74;US\n",
      "\n",
      "Datsun B210;31.0;4;79.00;67.00;1950.;19.0;74;Japan\n",
      "\n",
      "Ford Pinto;26.0;4;122.0;80.00;2451.;16.5;74;US\n",
      "\n",
      "Toyota Corolla 1200;32.0;4;71.00;65.00;1836.;21.0;74;Japan\n",
      "\n",
      "Chevrolet Vega;25.0;4;140.0;75.00;2542.;17.0;74;US\n",
      "\n",
      "Chevrolet Chevelle Malibu Classic;16.0;6;250.0;100.0;3781.;17.0;74;US\n",
      "\n",
      "AMC Matador;16.0;6;258.0;110.0;3632.;18.0;74;US\n",
      "\n",
      "Plymouth Satellite Sebring;18.0;6;225.0;105.0;3613.;16.5;74;US\n",
      "\n",
      "Ford Gran Torino;16.0;8;302.0;140.0;4141.;14.0;74;US\n",
      "\n",
      "Buick Century Luxus (sw);13.0;8;350.0;150.0;4699.;14.5;74;US\n",
      "\n",
      "Dodge Coronet Custom (sw);14.0;8;318.0;150.0;4457.;13.5;74;US\n",
      "\n",
      "Ford Gran Torino (sw);14.0;8;302.0;140.0;4638.;16.0;74;US\n",
      "\n",
      "AMC Matador (sw);14.0;8;304.0;150.0;4257.;15.5;74;US\n",
      "\n",
      "Audi Fox;29.0;4;98.00;83.00;2219.;16.5;74;Europe\n",
      "\n",
      "Volkswagen Dasher;26.0;4;79.00;67.00;1963.;15.5;74;Europe\n",
      "\n",
      "Opel Manta;26.0;4;97.00;78.00;2300.;14.5;74;Europe\n",
      "\n",
      "Toyota Corolla;31.0;4;76.00;52.00;1649.;16.5;74;Japan\n",
      "\n",
      "Datsun 710;32.0;4;83.00;61.00;2003.;19.0;74;Japan\n",
      "\n",
      "Dodge Colt;28.0;4;90.00;75.00;2125.;14.5;74;US\n",
      "\n",
      "Fiat 128;24.0;4;90.00;75.00;2108.;15.5;74;Europe\n",
      "\n",
      "Fiat 124 TC;26.0;4;116.0;75.00;2246.;14.0;74;Europe\n",
      "\n",
      "Honda Civic;24.0;4;120.0;97.00;2489.;15.0;74;Japan\n",
      "\n",
      "Subaru;26.0;4;108.0;93.00;2391.;15.5;74;Japan\n",
      "\n",
      "Fiat x1.9;31.0;4;79.00;67.00;2000.;16.0;74;Europe\n",
      "\n",
      "Plymouth Valiant Custom;19.0;6;225.0;95.00;3264.;16.0;75;US\n",
      "\n",
      "Chevrolet Nova;18.0;6;250.0;105.0;3459.;16.0;75;US\n",
      "\n",
      "Mercury Monarch;15.0;6;250.0;72.00;3432.;21.0;75;US\n",
      "\n",
      "Ford Maverick;15.0;6;250.0;72.00;3158.;19.5;75;US\n",
      "\n",
      "Pontiac Catalina;16.0;8;400.0;170.0;4668.;11.5;75;US\n",
      "\n",
      "Chevrolet Bel Air;15.0;8;350.0;145.0;4440.;14.0;75;US\n",
      "\n",
      "Plymouth Grand Fury;16.0;8;318.0;150.0;4498.;14.5;75;US\n",
      "\n",
      "Ford LTD;14.0;8;351.0;148.0;4657.;13.5;75;US\n",
      "\n",
      "Buick Century;17.0;6;231.0;110.0;3907.;21.0;75;US\n",
      "\n",
      "Chevrolete Chevelle Malibu;16.0;6;250.0;105.0;3897.;18.5;75;US\n",
      "\n",
      "AMC Matador;15.0;6;258.0;110.0;3730.;19.0;75;US\n",
      "\n",
      "Plymouth Fury;18.0;6;225.0;95.00;3785.;19.0;75;US\n",
      "\n",
      "Buick Skyhawk;21.0;6;231.0;110.0;3039.;15.0;75;US\n",
      "\n",
      "Chevrolet Monza 2+2;20.0;8;262.0;110.0;3221.;13.5;75;US\n",
      "\n",
      "Ford Mustang II;13.0;8;302.0;129.0;3169.;12.0;75;US\n",
      "\n",
      "Toyota Corolla;29.0;4;97.00;75.00;2171.;16.0;75;Japan\n",
      "\n",
      "Ford Pinto;23.0;4;140.0;83.00;2639.;17.0;75;US\n",
      "\n",
      "AMC Gremlin;20.0;6;232.0;100.0;2914.;16.0;75;US\n",
      "\n",
      "Pontiac Astro;23.0;4;140.0;78.00;2592.;18.5;75;US\n",
      "\n",
      "Toyota Corolla;24.0;4;134.0;96.00;2702.;13.5;75;Japan\n",
      "\n",
      "Volkswagen Dasher;25.0;4;90.00;71.00;2223.;16.5;75;Europe\n",
      "\n",
      "Datsun 710;24.0;4;119.0;97.00;2545.;17.0;75;Japan\n",
      "\n",
      "Ford Pinto;18.0;6;171.0;97.00;2984.;14.5;75;US\n",
      "\n",
      "Volkswagen Rabbit;29.0;4;90.00;70.00;1937.;14.0;75;Europe\n",
      "\n",
      "AMC Pacer;19.0;6;232.0;90.00;3211.;17.0;75;US\n",
      "\n",
      "Audi 100LS;23.0;4;115.0;95.00;2694.;15.0;75;Europe\n",
      "\n",
      "Peugeot 504;23.0;4;120.0;88.00;2957.;17.0;75;Europe\n",
      "\n",
      "Volvo 244DL;22.0;4;121.0;98.00;2945.;14.5;75;Europe\n",
      "\n",
      "Saab 99LE;25.0;4;121.0;115.0;2671.;13.5;75;Europe\n",
      "\n",
      "Honda Civic CVCC;33.0;4;91.00;53.00;1795.;17.5;75;Japan\n",
      "\n",
      "Fiat 131;28.0;4;107.0;86.00;2464.;15.5;76;Europe\n",
      "\n",
      "Opel 1900;25.0;4;116.0;81.00;2220.;16.9;76;Europe\n",
      "\n",
      "Capri ii;25.0;4;140.0;92.00;2572.;14.9;76;US\n",
      "\n",
      "Dodge Colt;26.0;4;98.00;79.00;2255.;17.7;76;US\n",
      "\n",
      "Renault 12tl;27.0;4;101.0;83.00;2202.;15.3;76;Europe\n",
      "\n",
      "Chevrolet Chevelle Malibu Classic;17.5;8;305.0;140.0;4215.;13.0;76;US\n",
      "\n",
      "Dodge Coronet Brougham;16.0;8;318.0;150.0;4190.;13.0;76;US\n",
      "\n",
      "AMC Matador;15.5;8;304.0;120.0;3962.;13.9;76;US\n",
      "\n",
      "Ford Gran Torino;14.5;8;351.0;152.0;4215.;12.8;76;US\n",
      "\n",
      "Plymouth Valiant;22.0;6;225.0;100.0;3233.;15.4;76;US\n",
      "\n",
      "Chevrolet Nova;22.0;6;250.0;105.0;3353.;14.5;76;US\n",
      "\n",
      "Ford Maverick;24.0;6;200.0;81.00;3012.;17.6;76;US\n",
      "\n",
      "AMC Hornet;22.5;6;232.0;90.00;3085.;17.6;76;US\n",
      "\n",
      "Chevrolet Chevette;29.0;4;85.00;52.00;2035.;22.2;76;US\n",
      "\n",
      "Chevrolet Woody;24.5;4;98.00;60.00;2164.;22.1;76;US\n",
      "\n",
      "Volkswagen Rabbit;29.0;4;90.00;70.00;1937.;14.2;76;Europe\n",
      "\n",
      "Honda Civic;33.0;4;91.00;53.00;1795.;17.4;76;Japan\n",
      "\n",
      "Dodge Aspen SE;20.0;6;225.0;100.0;3651.;17.7;76;US\n",
      "\n",
      "Ford Grenada ghia;18.0;6;250.0;78.00;3574.;21.0;76;US\n",
      "\n",
      "Pontiac Ventura SJ;18.5;6;250.0;110.0;3645.;16.2;76;US\n",
      "\n",
      "AMC Pacer d/l;17.5;6;258.0;95.00;3193.;17.8;76;US\n",
      "\n",
      "Volkswagen Rabbit;29.5;4;97.00;71.00;1825.;12.2;76;Europe\n",
      "\n",
      "Datsun B-210;32.0;4;85.00;70.00;1990.;17.0;76;Japan\n",
      "\n",
      "Toyota Corolla;28.0;4;97.00;75.00;2155.;16.4;76;Japan\n",
      "\n",
      "Ford Pinto;26.5;4;140.0;72.00;2565.;13.6;76;US\n",
      "\n",
      "Volvo 245;20.0;4;130.0;102.0;3150.;15.7;76;Europe\n",
      "\n",
      "Plymouth Volare Premier v8;13.0;8;318.0;150.0;3940.;13.2;76;US\n",
      "\n",
      "Peugeot 504;19.0;4;120.0;88.00;3270.;21.9;76;Europe\n",
      "\n",
      "Toyota Mark II;19.0;6;156.0;108.0;2930.;15.5;76;Japan\n",
      "\n",
      "Mercedes-Benz 280s;16.5;6;168.0;120.0;3820.;16.7;76;Europe\n",
      "\n",
      "Cadillac Seville;16.5;8;350.0;180.0;4380.;12.1;76;US\n",
      "\n",
      "Chevrolet C10;13.0;8;350.0;145.0;4055.;12.0;76;US\n",
      "\n",
      "Ford F108;13.0;8;302.0;130.0;3870.;15.0;76;US\n",
      "\n",
      "Dodge D100;13.0;8;318.0;150.0;3755.;14.0;76;US\n",
      "\n",
      "Honda Accord CVCC;31.5;4;98.00;68.00;2045.;18.5;77;Japan\n",
      "\n",
      "Buick Opel Isuzu Deluxe;30.0;4;111.0;80.00;2155.;14.8;77;US\n",
      "\n",
      "Renault 5 GTL;36.0;4;79.00;58.00;1825.;18.6;77;Europe\n",
      "\n",
      "Plymouth Arrow GS;25.5;4;122.0;96.00;2300.;15.5;77;US\n",
      "\n",
      "Datsun F-10 Hatchback;33.5;4;85.00;70.00;1945.;16.8;77;Japan\n",
      "\n",
      "Chevrolet Caprice Classic;17.5;8;305.0;145.0;3880.;12.5;77;US\n",
      "\n",
      "Oldsmobile Cutlass Supreme;17.0;8;260.0;110.0;4060.;19.0;77;US\n",
      "\n",
      "Dodge Monaco Brougham;15.5;8;318.0;145.0;4140.;13.7;77;US\n",
      "\n",
      "Mercury Cougar Brougham;15.0;8;302.0;130.0;4295.;14.9;77;US\n",
      "\n",
      "Chevrolet Concours;17.5;6;250.0;110.0;3520.;16.4;77;US\n",
      "\n",
      "Buick Skylark;20.5;6;231.0;105.0;3425.;16.9;77;US\n",
      "\n",
      "Plymouth Volare Custom;19.0;6;225.0;100.0;3630.;17.7;77;US\n",
      "\n",
      "Ford Grenada;18.5;6;250.0;98.00;3525.;19.0;77;US\n",
      "\n",
      "Pontiac Grand Prix LJ;16.0;8;400.0;180.0;4220.;11.1;77;US\n",
      "\n",
      "Chevrolet Monte Carlo Landau;15.5;8;350.0;170.0;4165.;11.4;77;US\n",
      "\n",
      "Chrysler Cordoba;15.5;8;400.0;190.0;4325.;12.2;77;US\n",
      "\n",
      "Ford Thunderbird;16.0;8;351.0;149.0;4335.;14.5;77;US\n",
      "\n",
      "Volkswagen Rabbit Custom;29.0;4;97.00;78.00;1940.;14.5;77;Europe\n",
      "\n",
      "Pontiac Sunbird Coupe;24.5;4;151.0;88.00;2740.;16.0;77;US\n",
      "\n",
      "Toyota Corolla Liftback;26.0;4;97.00;75.00;2265.;18.2;77;Japan\n",
      "\n",
      "Ford Mustang II 2+2;25.5;4;140.0;89.00;2755.;15.8;77;US\n",
      "\n",
      "Chevrolet Chevette;30.5;4;98.00;63.00;2051.;17.0;77;US\n",
      "\n",
      "Dodge Colt m/m;33.5;4;98.00;83.00;2075.;15.9;77;US\n",
      "\n",
      "Subaru DL;30.0;4;97.00;67.00;1985.;16.4;77;Japan\n",
      "\n",
      "Volkswagen Dasher;30.5;4;97.00;78.00;2190.;14.1;77;Europe\n",
      "\n",
      "Datsun 810;22.0;6;146.0;97.00;2815.;14.5;77;Japan\n",
      "\n",
      "BMW 320i;21.5;4;121.0;110.0;2600.;12.8;77;Europe\n",
      "\n",
      "Mazda RX-4;21.5;3;80.00;110.0;2720.;13.5;77;Japan\n",
      "\n",
      "Volkswagen Rabbit Custom Diesel;43.1;4;90.00;48.00;1985.;21.5;78;Europe\n",
      "\n",
      "Ford Fiesta;36.1;4;98.00;66.00;1800.;14.4;78;US\n",
      "\n",
      "Mazda GLC Deluxe;32.8;4;78.00;52.00;1985.;19.4;78;Japan\n",
      "\n",
      "Datsun B210 GX;39.4;4;85.00;70.00;2070.;18.6;78;Japan\n",
      "\n",
      "Honda Civic CVCC;36.1;4;91.00;60.00;1800.;16.4;78;Japan\n",
      "\n",
      "Oldsmobile Cutlass Salon Brougham;19.9;8;260.0;110.0;3365.;15.5;78;US\n",
      "\n",
      "Dodge Diplomat;19.4;8;318.0;140.0;3735.;13.2;78;US\n",
      "\n",
      "Mercury Monarch ghia;20.2;8;302.0;139.0;3570.;12.8;78;US\n",
      "\n",
      "Pontiac Phoenix LJ;19.2;6;231.0;105.0;3535.;19.2;78;US\n",
      "\n",
      "Chevrolet Malibu;20.5;6;200.0;95.00;3155.;18.2;78;US\n",
      "\n",
      "Ford Fairmont (auto);20.2;6;200.0;85.00;2965.;15.8;78;US\n",
      "\n",
      "Ford Fairmont (man);25.1;4;140.0;88.00;2720.;15.4;78;US\n",
      "\n",
      "Plymouth Volare;20.5;6;225.0;100.0;3430.;17.2;78;US\n",
      "\n",
      "AMC Concord;19.4;6;232.0;90.00;3210.;17.2;78;US\n",
      "\n",
      "Buick Century Special;20.6;6;231.0;105.0;3380.;15.8;78;US\n",
      "\n",
      "Mercury Zephyr;20.8;6;200.0;85.00;3070.;16.7;78;US\n",
      "\n",
      "Dodge Aspen;18.6;6;225.0;110.0;3620.;18.7;78;US\n",
      "\n",
      "AMC Concord d/l;18.1;6;258.0;120.0;3410.;15.1;78;US\n",
      "\n",
      "Chevrolet Monte Carlo Landau;19.2;8;305.0;145.0;3425.;13.2;78;US\n",
      "\n",
      "Buick Regal Sport Coupe (turbo);17.7;6;231.0;165.0;3445.;13.4;78;US\n",
      "\n",
      "Ford Futura;18.1;8;302.0;139.0;3205.;11.2;78;US\n",
      "\n",
      "Dodge Magnum XE;17.5;8;318.0;140.0;4080.;13.7;78;US\n",
      "\n",
      "Chevrolet Chevette;30.0;4;98.00;68.00;2155.;16.5;78;US\n",
      "\n",
      "Toyota Corolla;27.5;4;134.0;95.00;2560.;14.2;78;Japan\n",
      "\n",
      "Datsun 510;27.2;4;119.0;97.00;2300.;14.7;78;Japan\n",
      "\n",
      "Dodge Omni;30.9;4;105.0;75.00;2230.;14.5;78;US\n",
      "\n",
      "Toyota Celica GT Liftback;21.1;4;134.0;95.00;2515.;14.8;78;Japan\n",
      "\n",
      "Plymouth Sapporo;23.2;4;156.0;105.0;2745.;16.7;78;US\n",
      "\n",
      "Oldsmobile Starfire SX;23.8;4;151.0;85.00;2855.;17.6;78;US\n",
      "\n",
      "Datsun 200-SX;23.9;4;119.0;97.00;2405.;14.9;78;Japan\n",
      "\n",
      "Audi 5000;20.3;5;131.0;103.0;2830.;15.9;78;Europe\n",
      "\n",
      "Volvo 264gl;17.0;6;163.0;125.0;3140.;13.6;78;Europe\n",
      "\n",
      "Saab 99gle;21.6;4;121.0;115.0;2795.;15.7;78;Europe\n",
      "\n",
      "Peugeot 604sl;16.2;6;163.0;133.0;3410.;15.8;78;Europe\n",
      "\n",
      "Volkswagen Scirocco;31.5;4;89.00;71.00;1990.;14.9;78;Europe\n",
      "\n",
      "Honda Accord LX;29.5;4;98.00;68.00;2135.;16.6;78;Japan\n",
      "\n",
      "Pontiac Lemans V6;21.5;6;231.0;115.0;3245.;15.4;79;US\n",
      "\n",
      "Mercury Zephyr 6;19.8;6;200.0;85.00;2990.;18.2;79;US\n",
      "\n",
      "Ford Fairmont 4;22.3;4;140.0;88.00;2890.;17.3;79;US\n",
      "\n",
      "AMC Concord DL 6;20.2;6;232.0;90.00;3265.;18.2;79;US\n",
      "\n",
      "Dodge Aspen 6;20.6;6;225.0;110.0;3360.;16.6;79;US\n",
      "\n",
      "Chevrolet Caprice Classic;17.0;8;305.0;130.0;3840.;15.4;79;US\n",
      "\n",
      "Ford LTD Landau;17.6;8;302.0;129.0;3725.;13.4;79;US\n",
      "\n",
      "Mercury Grand Marquis;16.5;8;351.0;138.0;3955.;13.2;79;US\n",
      "\n",
      "Dodge St. Regis;18.2;8;318.0;135.0;3830.;15.2;79;US\n",
      "\n",
      "Buick Estate Wagon (sw);16.9;8;350.0;155.0;4360.;14.9;79;US\n",
      "\n",
      "Ford Country Squire (sw);15.5;8;351.0;142.0;4054.;14.3;79;US\n",
      "\n",
      "Chevrolet Malibu Classic (sw);19.2;8;267.0;125.0;3605.;15.0;79;US\n",
      "\n",
      "Chrysler Lebaron Town @ Country (sw);18.5;8;360.0;150.0;3940.;13.0;79;US\n",
      "\n",
      "Volkswagen Rabbit Custom;31.9;4;89.00;71.00;1925.;14.0;79;Europe\n",
      "\n",
      "Mazda GLC Deluxe;34.1;4;86.00;65.00;1975.;15.2;79;Japan\n",
      "\n",
      "Dodge Colt Hatchback Custom;35.7;4;98.00;80.00;1915.;14.4;79;US\n",
      "\n",
      "AMC Spirit DL;27.4;4;121.0;80.00;2670.;15.0;79;US\n",
      "\n",
      "Mercedes Benz 300d;25.4;5;183.0;77.00;3530.;20.1;79;Europe\n",
      "\n",
      "Cadillac Eldorado;23.0;8;350.0;125.0;3900.;17.4;79;US\n",
      "\n",
      "Peugeot 504;27.2;4;141.0;71.00;3190.;24.8;79;Europe\n",
      "\n",
      "Oldsmobile Cutlass Salon Brougham;23.9;8;260.0;90.00;3420.;22.2;79;US\n",
      "\n",
      "Plymouth Horizon;34.2;4;105.0;70.00;2200.;13.2;79;US\n",
      "\n",
      "Plymouth Horizon TC3;34.5;4;105.0;70.00;2150.;14.9;79;US\n",
      "\n",
      "Datsun 210;31.8;4;85.00;65.00;2020.;19.2;79;Japan\n",
      "\n",
      "Fiat Strada Custom;37.3;4;91.00;69.00;2130.;14.7;79;Europe\n",
      "\n",
      "Buick Skylark Limited;28.4;4;151.0;90.00;2670.;16.0;79;US\n",
      "\n",
      "Chevrolet Citation;28.8;6;173.0;115.0;2595.;11.3;79;US\n",
      "\n",
      "Oldsmobile Omega Brougham;26.8;6;173.0;115.0;2700.;12.9;79;US\n",
      "\n",
      "Pontiac Phoenix;33.5;4;151.0;90.00;2556.;13.2;79;US\n",
      "\n",
      "Volkswagen Rabbit;41.5;4;98.00;76.00;2144.;14.7;80;Europe\n",
      "\n",
      "Toyota Corolla Tercel;38.1;4;89.00;60.00;1968.;18.8;80;Japan\n",
      "\n",
      "Chevrolet Chevette;32.1;4;98.00;70.00;2120.;15.5;80;US\n",
      "\n",
      "Datsun 310;37.2;4;86.00;65.00;2019.;16.4;80;Japan\n",
      "\n",
      "Chevrolet Citation;28.0;4;151.0;90.00;2678.;16.5;80;US\n",
      "\n",
      "Ford Fairmont;26.4;4;140.0;88.00;2870.;18.1;80;US\n",
      "\n",
      "AMC Concord;24.3;4;151.0;90.00;3003.;20.1;80;US\n",
      "\n",
      "Dodge Aspen;19.1;6;225.0;90.00;3381.;18.7;80;US\n",
      "\n",
      "Audi 4000;34.3;4;97.00;78.00;2188.;15.8;80;Europe\n",
      "\n",
      "Toyota Corolla Liftback;29.8;4;134.0;90.00;2711.;15.5;80;Japan\n",
      "\n",
      "Mazda 626;31.3;4;120.0;75.00;2542.;17.5;80;Japan\n",
      "\n",
      "Datsun 510 Hatchback;37.0;4;119.0;92.00;2434.;15.0;80;Japan\n",
      "\n",
      "Toyota Corolla;32.2;4;108.0;75.00;2265.;15.2;80;Japan\n",
      "\n",
      "Mazda GLC;46.6;4;86.00;65.00;2110.;17.9;80;Japan\n",
      "\n",
      "Dodge Colt;27.9;4;156.0;105.0;2800.;14.4;80;US\n",
      "\n",
      "Datsun 210;40.8;4;85.00;65.00;2110.;19.2;80;Japan\n",
      "\n",
      "Volkswagen Rabbit C (Diesel);44.3;4;90.00;48.00;2085.;21.7;80;Europe\n",
      "\n",
      "Volkswagen Dasher (diesel);43.4;4;90.00;48.00;2335.;23.7;80;Europe\n",
      "\n",
      "Audi 5000s (diesel);36.4;5;121.0;67.00;2950.;19.9;80;Europe\n",
      "\n",
      "Mercedes-Benz 240d;30.0;4;146.0;67.00;3250.;21.8;80;Europe\n",
      "\n",
      "Honda Civic 1500 gl;44.6;4;91.00;67.00;1850.;13.8;80;Japan\n",
      "\n",
      "Renault Lecar Deluxe;40.9;4;85.00;0;1835.;17.3;80;Europe\n",
      "\n",
      "Subaru DL;33.8;4;97.00;67.00;2145.;18.0;80;Japan\n",
      "\n",
      "Volkswagen Rabbit;29.8;4;89.00;62.00;1845.;15.3;80;Europe\n",
      "\n",
      "Datsun 280-ZX;32.7;6;168.0;132.0;2910.;11.4;80;Japan\n",
      "\n",
      "Mazda RX-7 GS;23.7;3;70.00;100.0;2420.;12.5;80;Japan\n",
      "\n",
      "Triumph TR7 Coupe;35.0;4;122.0;88.00;2500.;15.1;80;Europe\n",
      "\n",
      "Ford Mustang Cobra;23.6;4;140.0;0;2905.;14.3;80;US\n",
      "\n",
      "Honda Accord;32.4;4;107.0;72.00;2290.;17.0;80;Japan\n",
      "\n",
      "Plymouth Reliant;27.2;4;135.0;84.00;2490.;15.7;81;US\n",
      "\n",
      "Buick Skylark;26.6;4;151.0;84.00;2635.;16.4;81;US\n",
      "\n",
      "Dodge Aries Wagon (sw);25.8;4;156.0;92.00;2620.;14.4;81;US\n",
      "\n",
      "Chevrolet Citation;23.5;6;173.0;110.0;2725.;12.6;81;US\n",
      "\n",
      "Plymouth Reliant;30.0;4;135.0;84.00;2385.;12.9;81;US\n",
      "\n",
      "Toyota Starlet;39.1;4;79.00;58.00;1755.;16.9;81;Japan\n",
      "\n",
      "Plymouth Champ;39.0;4;86.00;64.00;1875.;16.4;81;US\n",
      "\n",
      "Honda Civic 1300;35.1;4;81.00;60.00;1760.;16.1;81;Japan\n",
      "\n",
      "Subaru;32.3;4;97.00;67.00;2065.;17.8;81;Japan\n",
      "\n",
      "Datsun 210 MPG;37.0;4;85.00;65.00;1975.;19.4;81;Japan\n",
      "\n",
      "Toyota Tercel;37.7;4;89.00;62.00;2050.;17.3;81;Japan\n",
      "\n",
      "Mazda GLC 4;34.1;4;91.00;68.00;1985.;16.0;81;Japan\n",
      "\n",
      "Plymouth Horizon 4;34.7;4;105.0;63.00;2215.;14.9;81;US\n",
      "\n",
      "Ford Escort 4W;34.4;4;98.00;65.00;2045.;16.2;81;US\n",
      "\n",
      "Ford Escort 2H;29.9;4;98.00;65.00;2380.;20.7;81;US\n",
      "\n",
      "Volkswagen Jetta;33.0;4;105.0;74.00;2190.;14.2;81;Europe\n",
      "\n",
      "Renault 18i;34.5;4;100.0;0;2320.;15.8;81;Europe\n",
      "\n",
      "Honda Prelude;33.7;4;107.0;75.00;2210.;14.4;81;Japan\n",
      "\n",
      "Toyota Corolla;32.4;4;108.0;75.00;2350.;16.8;81;Japan\n",
      "\n",
      "Datsun 200SX;32.9;4;119.0;100.0;2615.;14.8;81;Japan\n",
      "\n",
      "Mazda 626;31.6;4;120.0;74.00;2635.;18.3;81;Japan\n",
      "\n",
      "Peugeot 505s Turbo Diesel;28.1;4;141.0;80.00;3230.;20.4;81;Europe\n",
      "\n",
      "Saab 900s;0;4;121.0;110.0;2800.;15.4;81;Europe\n",
      "\n",
      "Volvo Diesel;30.7;6;145.0;76.00;3160.;19.6;81;Europe\n",
      "\n",
      "Toyota Cressida;25.4;6;168.0;116.0;2900.;12.6;81;Japan\n",
      "\n",
      "Datsun 810 Maxima;24.2;6;146.0;120.0;2930.;13.8;81;Japan\n",
      "\n",
      "Buick Century;22.4;6;231.0;110.0;3415.;15.8;81;US\n",
      "\n",
      "Oldsmobile Cutlass LS;26.6;8;350.0;105.0;3725.;19.0;81;US\n",
      "\n",
      "Ford Grenada gl;20.2;6;200.0;88.00;3060.;17.1;81;US\n",
      "\n",
      "Chrysler Lebaron Salon;17.6;6;225.0;85.00;3465.;16.6;81;US\n",
      "\n",
      "Chevrolet Cavalier;28.0;4;112.0;88.00;2605.;19.6;82;US\n",
      "\n",
      "Chevrolet Cavalier Wagon;27.0;4;112.0;88.00;2640.;18.6;82;US\n",
      "\n",
      "Chevrolet Cavalier 2-door;34.0;4;112.0;88.00;2395.;18.0;82;US\n",
      "\n",
      "Pontiac J2000 SE Hatchback;31.0;4;112.0;85.00;2575.;16.2;82;US\n",
      "\n",
      "Dodge Aries SE;29.0;4;135.0;84.00;2525.;16.0;82;US\n",
      "\n",
      "Pontiac Phoenix;27.0;4;151.0;90.00;2735.;18.0;82;US\n",
      "\n",
      "Ford Fairmont Futura;24.0;4;140.0;92.00;2865.;16.4;82;US\n",
      "\n",
      "AMC Concord DL;23.0;4;151.0;0;3035.;20.5;82;US\n",
      "\n",
      "Volkswagen Rabbit l;36.0;4;105.0;74.00;1980.;15.3;82;Europe\n",
      "\n",
      "Mazda GLC Custom l;37.0;4;91.00;68.00;2025.;18.2;82;Japan\n",
      "\n",
      "Mazda GLC Custom;31.0;4;91.00;68.00;1970.;17.6;82;Japan\n",
      "\n",
      "Plymouth Horizon Miser;38.0;4;105.0;63.00;2125.;14.7;82;US\n",
      "\n",
      "Mercury Lynx l;36.0;4;98.00;70.00;2125.;17.3;82;US\n",
      "\n",
      "Nissan Stanza XE;36.0;4;120.0;88.00;2160.;14.5;82;Japan\n",
      "\n",
      "Honda Accord;36.0;4;107.0;75.00;2205.;14.5;82;Japan\n",
      "\n",
      "Toyota Corolla;34.0;4;108.0;70.00;2245;16.9;82;Japan\n",
      "\n",
      "Honda Civic;38.0;4;91.00;67.00;1965.;15.0;82;Japan\n",
      "\n",
      "Honda Civic (auto);32.0;4;91.00;67.00;1965.;15.7;82;Japan\n",
      "\n",
      "Datsun 310 GX;38.0;4;91.00;67.00;1995.;16.2;82;Japan\n",
      "\n",
      "Buick Century Limited;25.0;6;181.0;110.0;2945.;16.4;82;US\n",
      "\n",
      "Oldsmobile Cutlass Ciera (diesel);38.0;6;262.0;85.00;3015.;17.0;82;US\n",
      "\n",
      "Chrysler Lebaron Medallion;26.0;4;156.0;92.00;2585.;14.5;82;US\n",
      "\n",
      "Ford Grenada l;22.0;6;232.0;112.0;2835;14.7;82;US\n",
      "\n",
      "Toyota Celica GT;32.0;4;144.0;96.00;2665.;13.9;82;Japan\n",
      "\n",
      "Dodge Charger 2.2;36.0;4;135.0;84.00;2370.;13.0;82;US\n",
      "\n",
      "Chevrolet Camaro;27.0;4;151.0;90.00;2950.;17.3;82;US\n",
      "\n",
      "Ford Mustang GL;27.0;4;140.0;86.00;2790.;15.6;82;US\n",
      "\n",
      "Volkswagen Pickup;44.0;4;97.00;52.00;2130.;24.6;82;Europe\n",
      "\n",
      "Dodge Rampage;32.0;4;135.0;84.00;2295.;11.6;82;US\n",
      "\n",
      "Ford Ranger;28.0;4;120.0;79.00;2625.;18.6;82;US\n",
      "\n",
      "Chevy S-10;31.0;4;119.0;82.00;2720.;19.4;82;US\n",
      "\n"
     ]
    }
   ],
   "source": [
    "with open('cars.csv') as file:\n",
    "    for line in file:\n",
    "        print(line)    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As we can see, the values are delimited by `;` and the first two lines consist of the column names, and column types.\n",
    "\n",
    "The reason for the spacing between each line is that each line ends with a newline, and our print statement also emits a newline by default. So we'll have to strip those out."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here's what we want to do: \n",
    "* read the first line to get the column headers and create a named tuple class\n",
    "* read data types from second line and store this so we can cast the strings we are reading to the correct data type\n",
    "* read the data rows and parse them into a named tuples"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We could do it this way:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Car', 'MPG', 'Cylinders', 'Displacement', 'Horsepower', 'Weight', 'Acceleration', 'Model', 'Origin']\n",
      "['STRING', 'DOUBLE', 'INT', 'DOUBLE', 'DOUBLE', 'DOUBLE', 'DOUBLE', 'INT', 'CAT']\n",
      "['Chevrolet Chevelle Malibu', '18.0', '8', '307.0', '130.0', '3504.', '12.0', '70', 'US']\n",
      "['Buick Skylark 320', '15.0', '8', '350.0', '165.0', '3693.', '11.5', '70', 'US']\n",
      "['Plymouth Satellite', '18.0', '8', '318.0', '150.0', '3436.', '11.0', '70', 'US']\n",
      "['AMC Rebel SST', '16.0', '8', '304.0', '150.0', '3433.', '12.0', '70', 'US']\n",
      "['Ford Torino', '17.0', '8', '302.0', '140.0', '3449.', '10.5', '70', 'US']\n",
      "['Ford Galaxie 500', '15.0', '8', '429.0', '198.0', '4341.', '10.0', '70', 'US']\n",
      "['Chevrolet Impala', '14.0', '8', '454.0', '220.0', '4354.', '9.0', '70', 'US']\n",
      "['Plymouth Fury iii', '14.0', '8', '440.0', '215.0', '4312.', '8.5', '70', 'US']\n",
      "['Pontiac Catalina', '14.0', '8', '455.0', '225.0', '4425.', '10.0', '70', 'US']\n",
      "['AMC Ambassador DPL', '15.0', '8', '390.0', '190.0', '3850.', '8.5', '70', 'US']\n",
      "['Citroen DS-21 Pallas', '0', '4', '133.0', '115.0', '3090.', '17.5', '70', 'Europe']\n",
      "['Chevrolet Chevelle Concours (sw)', '0', '8', '350.0', '165.0', '4142.', '11.5', '70', 'US']\n",
      "['Ford Torino (sw)', '0', '8', '351.0', '153.0', '4034.', '11.0', '70', 'US']\n",
      "['Plymouth Satellite (sw)', '0', '8', '383.0', '175.0', '4166.', '10.5', '70', 'US']\n",
      "['AMC Rebel SST (sw)', '0', '8', '360.0', '175.0', '3850.', '11.0', '70', 'US']\n",
      "['Dodge Challenger SE', '15.0', '8', '383.0', '170.0', '3563.', '10.0', '70', 'US']\n",
      "[\"Plymouth 'Cuda 340\", '14.0', '8', '340.0', '160.0', '3609.', '8.0', '70', 'US']\n",
      "['Ford Mustang Boss 302', '0', '8', '302.0', '140.0', '3353.', '8.0', '70', 'US']\n",
      "['Chevrolet Monte Carlo', '15.0', '8', '400.0', '150.0', '3761.', '9.5', '70', 'US']\n",
      "['Buick Estate Wagon (sw)', '14.0', '8', '455.0', '225.0', '3086.', '10.0', '70', 'US']\n",
      "['Toyota Corolla Mark ii', '24.0', '4', '113.0', '95.00', '2372.', '15.0', '70', 'Japan']\n",
      "['Plymouth Duster', '22.0', '6', '198.0', '95.00', '2833.', '15.5', '70', 'US']\n",
      "['AMC Hornet', '18.0', '6', '199.0', '97.00', '2774.', '15.5', '70', 'US']\n",
      "['Ford Maverick', '21.0', '6', '200.0', '85.00', '2587.', '16.0', '70', 'US']\n",
      "['Datsun PL510', '27.0', '4', '97.00', '88.00', '2130.', '14.5', '70', 'Japan']\n",
      "['Volkswagen 1131 Deluxe Sedan', '26.0', '4', '97.00', '46.00', '1835.', '20.5', '70', 'Europe']\n",
      "['Peugeot 504', '25.0', '4', '110.0', '87.00', '2672.', '17.5', '70', 'Europe']\n",
      "['Audi 100 LS', '24.0', '4', '107.0', '90.00', '2430.', '14.5', '70', 'Europe']\n",
      "['Saab 99e', '25.0', '4', '104.0', '95.00', '2375.', '17.5', '70', 'Europe']\n",
      "['BMW 2002', '26.0', '4', '121.0', '113.0', '2234.', '12.5', '70', 'Europe']\n",
      "['AMC Gremlin', '21.0', '6', '199.0', '90.00', '2648.', '15.0', '70', 'US']\n",
      "['Ford F250', '10.0', '8', '360.0', '215.0', '4615.', '14.0', '70', 'US']\n",
      "['Chevy C20', '10.0', '8', '307.0', '200.0', '4376.', '15.0', '70', 'US']\n",
      "['Dodge D200', '11.0', '8', '318.0', '210.0', '4382.', '13.5', '70', 'US']\n",
      "['Hi 1200D', '9.0', '8', '304.0', '193.0', '4732.', '18.5', '70', 'US']\n",
      "['Datsun PL510', '27.0', '4', '97.00', '88.00', '2130.', '14.5', '71', 'Japan']\n",
      "['Chevrolet Vega 2300', '28.0', '4', '140.0', '90.00', '2264.', '15.5', '71', 'US']\n",
      "['Toyota Corolla', '25.0', '4', '113.0', '95.00', '2228.', '14.0', '71', 'Japan']\n",
      "['Ford Pinto', '25.0', '4', '98.00', '0', '2046.', '19.0', '71', 'US']\n",
      "['Volkswagen Super Beetle 117', '0', '4', '97.00', '48.00', '1978.', '20.0', '71', 'Europe']\n",
      "['AMC Gremlin', '19.0', '6', '232.0', '100.0', '2634.', '13.0', '71', 'US']\n",
      "['Plymouth Satellite Custom', '16.0', '6', '225.0', '105.0', '3439.', '15.5', '71', 'US']\n",
      "['Chevrolet Chevelle Malibu', '17.0', '6', '250.0', '100.0', '3329.', '15.5', '71', 'US']\n",
      "['Ford Torino 500', '19.0', '6', '250.0', '88.00', '3302.', '15.5', '71', 'US']\n",
      "['AMC Matador', '18.0', '6', '232.0', '100.0', '3288.', '15.5', '71', 'US']\n",
      "['Chevrolet Impala', '14.0', '8', '350.0', '165.0', '4209.', '12.0', '71', 'US']\n",
      "['Pontiac Catalina Brougham', '14.0', '8', '400.0', '175.0', '4464.', '11.5', '71', 'US']\n",
      "['Ford Galaxie 500', '14.0', '8', '351.0', '153.0', '4154.', '13.5', '71', 'US']\n",
      "['Plymouth Fury iii', '14.0', '8', '318.0', '150.0', '4096.', '13.0', '71', 'US']\n",
      "['Dodge Monaco (sw)', '12.0', '8', '383.0', '180.0', '4955.', '11.5', '71', 'US']\n",
      "['Ford Country Squire (sw)', '13.0', '8', '400.0', '170.0', '4746.', '12.0', '71', 'US']\n",
      "['Pontiac Safari (sw)', '13.0', '8', '400.0', '175.0', '5140.', '12.0', '71', 'US']\n",
      "['AMC Hornet Sportabout (sw)', '18.0', '6', '258.0', '110.0', '2962.', '13.5', '71', 'US']\n",
      "['Chevrolet Vega (sw)', '22.0', '4', '140.0', '72.00', '2408.', '19.0', '71', 'US']\n",
      "['Pontiac Firebird', '19.0', '6', '250.0', '100.0', '3282.', '15.0', '71', 'US']\n",
      "['Ford Mustang', '18.0', '6', '250.0', '88.00', '3139.', '14.5', '71', 'US']\n",
      "['Mercury Capri 2000', '23.0', '4', '122.0', '86.00', '2220.', '14.0', '71', 'US']\n",
      "['Opel 1900', '28.0', '4', '116.0', '90.00', '2123.', '14.0', '71', 'Europe']\n",
      "['Peugeot 304', '30.0', '4', '79.00', '70.00', '2074.', '19.5', '71', 'Europe']\n",
      "['Fiat 124B', '30.0', '4', '88.00', '76.00', '2065.', '14.5', '71', 'Europe']\n",
      "['Toyota Corolla 1200', '31.0', '4', '71.00', '65.00', '1773.', '19.0', '71', 'Japan']\n",
      "['Datsun 1200', '35.0', '4', '72.00', '69.00', '1613.', '18.0', '71', 'Japan']\n",
      "['Volkswagen Model 111', '27.0', '4', '97.00', '60.00', '1834.', '19.0', '71', 'Europe']\n",
      "['Plymouth Cricket', '26.0', '4', '91.00', '70.00', '1955.', '20.5', '71', 'US']\n",
      "['Toyota Corolla Hardtop', '24.0', '4', '113.0', '95.00', '2278.', '15.5', '72', 'Japan']\n",
      "['Dodge Colt Hardtop', '25.0', '4', '97.50', '80.00', '2126.', '17.0', '72', 'US']\n",
      "['Volkswagen Type 3', '23.0', '4', '97.00', '54.00', '2254.', '23.5', '72', 'Europe']\n",
      "['Chevrolet Vega', '20.0', '4', '140.0', '90.00', '2408.', '19.5', '72', 'US']\n",
      "['Ford Pinto Runabout', '21.0', '4', '122.0', '86.00', '2226.', '16.5', '72', 'US']\n",
      "['Chevrolet Impala', '13.0', '8', '350.0', '165.0', '4274.', '12.0', '72', 'US']\n",
      "['Pontiac Catalina', '14.0', '8', '400.0', '175.0', '4385.', '12.0', '72', 'US']\n",
      "['Plymouth Fury III', '15.0', '8', '318.0', '150.0', '4135.', '13.5', '72', 'US']\n",
      "['Ford Galaxie 500', '14.0', '8', '351.0', '153.0', '4129.', '13.0', '72', 'US']\n",
      "['AMC Ambassador SST', '17.0', '8', '304.0', '150.0', '3672.', '11.5', '72', 'US']\n",
      "['Mercury Marquis', '11.0', '8', '429.0', '208.0', '4633.', '11.0', '72', 'US']\n",
      "['Buick LeSabre Custom', '13.0', '8', '350.0', '155.0', '4502.', '13.5', '72', 'US']\n",
      "['Oldsmobile Delta 88 Royale', '12.0', '8', '350.0', '160.0', '4456.', '13.5', '72', 'US']\n",
      "['Chrysler Newport Royal', '13.0', '8', '400.0', '190.0', '4422.', '12.5', '72', 'US']\n",
      "['Mazda RX2 Coupe', '19.0', '3', '70.00', '97.00', '2330.', '13.5', '72', 'Japan']\n",
      "['AMC Matador (sw)', '15.0', '8', '304.0', '150.0', '3892.', '12.5', '72', 'US']\n",
      "['Chevrolet Chevelle Concours (sw)', '13.0', '8', '307.0', '130.0', '4098.', '14.0', '72', 'US']\n",
      "['Ford Gran Torino (sw)', '13.0', '8', '302.0', '140.0', '4294.', '16.0', '72', 'US']\n",
      "['Plymouth Satellite Custom (sw)', '14.0', '8', '318.0', '150.0', '4077.', '14.0', '72', 'US']\n",
      "['Volvo 145e (sw)', '18.0', '4', '121.0', '112.0', '2933.', '14.5', '72', 'Europe']\n",
      "['Volkswagen 411 (sw)', '22.0', '4', '121.0', '76.00', '2511.', '18.0', '72', 'Europe']\n",
      "['Peugeot 504 (sw)', '21.0', '4', '120.0', '87.00', '2979.', '19.5', '72', 'Europe']\n",
      "['Renault 12 (sw)', '26.0', '4', '96.00', '69.00', '2189.', '18.0', '72', 'Europe']\n",
      "['Ford Pinto (sw)', '22.0', '4', '122.0', '86.00', '2395.', '16.0', '72', 'US']\n",
      "['Datsun 510 (sw)', '28.0', '4', '97.00', '92.00', '2288.', '17.0', '72', 'Japan']\n",
      "['Toyota Corolla Mark II (sw)', '23.0', '4', '120.0', '97.00', '2506.', '14.5', '72', 'Japan']\n",
      "['Dodge Colt (sw)', '28.0', '4', '98.00', '80.00', '2164.', '15.0', '72', 'US']\n",
      "['Toyota Corolla 1600 (sw)', '27.0', '4', '97.00', '88.00', '2100.', '16.5', '72', 'Japan']\n",
      "['Buick Century 350', '13.0', '8', '350.0', '175.0', '4100.', '13.0', '73', 'US']\n",
      "['AMC Matador', '14.0', '8', '304.0', '150.0', '3672.', '11.5', '73', 'US']\n",
      "['Chevrolet Malibu', '13.0', '8', '350.0', '145.0', '3988.', '13.0', '73', 'US']\n",
      "['Ford Gran Torino', '14.0', '8', '302.0', '137.0', '4042.', '14.5', '73', 'US']\n",
      "['Dodge Coronet Custom', '15.0', '8', '318.0', '150.0', '3777.', '12.5', '73', 'US']\n",
      "['Mercury Marquis Brougham', '12.0', '8', '429.0', '198.0', '4952.', '11.5', '73', 'US']\n",
      "['Chevrolet Caprice Classic', '13.0', '8', '400.0', '150.0', '4464.', '12.0', '73', 'US']\n",
      "['Ford LTD', '13.0', '8', '351.0', '158.0', '4363.', '13.0', '73', 'US']\n",
      "['Plymouth Fury Gran Sedan', '14.0', '8', '318.0', '150.0', '4237.', '14.5', '73', 'US']\n",
      "['Chrysler New Yorker Brougham', '13.0', '8', '440.0', '215.0', '4735.', '11.0', '73', 'US']\n",
      "['Buick Electra 225 Custom', '12.0', '8', '455.0', '225.0', '4951.', '11.0', '73', 'US']\n",
      "['AMC Ambassador Brougham', '13.0', '8', '360.0', '175.0', '3821.', '11.0', '73', 'US']\n",
      "['Plymouth Valiant', '18.0', '6', '225.0', '105.0', '3121.', '16.5', '73', 'US']\n",
      "['Chevrolet Nova Custom', '16.0', '6', '250.0', '100.0', '3278.', '18.0', '73', 'US']\n",
      "['AMC Hornet', '18.0', '6', '232.0', '100.0', '2945.', '16.0', '73', 'US']\n",
      "['Ford Maverick', '18.0', '6', '250.0', '88.00', '3021.', '16.5', '73', 'US']\n",
      "['Plymouth Duster', '23.0', '6', '198.0', '95.00', '2904.', '16.0', '73', 'US']\n",
      "['Volkswagen Super Beetle', '26.0', '4', '97.00', '46.00', '1950.', '21.0', '73', 'Europe']\n",
      "['Chevrolet Impala', '11.0', '8', '400.0', '150.0', '4997.', '14.0', '73', 'US']\n",
      "['Ford Country', '12.0', '8', '400.0', '167.0', '4906.', '12.5', '73', 'US']\n",
      "['Plymouth Custom Suburb', '13.0', '8', '360.0', '170.0', '4654.', '13.0', '73', 'US']\n",
      "['Oldsmobile Vista Cruiser', '12.0', '8', '350.0', '180.0', '4499.', '12.5', '73', 'US']\n",
      "['AMC Gremlin', '18.0', '6', '232.0', '100.0', '2789.', '15.0', '73', 'US']\n",
      "['Toyota Camry', '20.0', '4', '97.00', '88.00', '2279.', '19.0', '73', 'Japan']\n",
      "['Chevrolet Vega', '21.0', '4', '140.0', '72.00', '2401.', '19.5', '73', 'US']\n",
      "['Datsun 610', '22.0', '4', '108.0', '94.00', '2379.', '16.5', '73', 'Japan']\n",
      "['Mazda RX3', '18.0', '3', '70.00', '90.00', '2124.', '13.5', '73', 'Japan']\n",
      "['Ford Pinto', '19.0', '4', '122.0', '85.00', '2310.', '18.5', '73', 'US']\n",
      "['Mercury Capri v6', '21.0', '6', '155.0', '107.0', '2472.', '14.0', '73', 'US']\n",
      "['Fiat 124 Sport Coupe', '26.0', '4', '98.00', '90.00', '2265.', '15.5', '73', 'Europe']\n",
      "['Chevrolet Monte Carlo S', '15.0', '8', '350.0', '145.0', '4082.', '13.0', '73', 'US']\n",
      "['Pontiac Grand Prix', '16.0', '8', '400.0', '230.0', '4278.', '9.50', '73', 'US']\n",
      "['Fiat 128', '29.0', '4', '68.00', '49.00', '1867.', '19.5', '73', 'Europe']\n",
      "['Opel Manta', '24.0', '4', '116.0', '75.00', '2158.', '15.5', '73', 'Europe']\n",
      "['Audi 100LS', '20.0', '4', '114.0', '91.00', '2582.', '14.0', '73', 'Europe']\n",
      "['Volvo 144ea', '19.0', '4', '121.0', '112.0', '2868.', '15.5', '73', 'Europe']\n",
      "['Dodge Dart Custom', '15.0', '8', '318.0', '150.0', '3399.', '11.0', '73', 'US']\n",
      "['Saab 99le', '24.0', '4', '121.0', '110.0', '2660.', '14.0', '73', 'Europe']\n",
      "['Toyota Mark II', '20.0', '6', '156.0', '122.0', '2807.', '13.5', '73', 'Japan']\n",
      "['Oldsmobile Omega', '11.0', '8', '350.0', '180.0', '3664.', '11.0', '73', 'US']\n",
      "['Plymouth Duster', '20.0', '6', '198.0', '95.00', '3102.', '16.5', '74', 'US']\n",
      "['Ford Maverick', '21.0', '6', '200.0', '0', '2875.', '17.0', '74', 'US']\n",
      "['AMC Hornet', '19.0', '6', '232.0', '100.0', '2901.', '16.0', '74', 'US']\n",
      "['Chevrolet Nova', '15.0', '6', '250.0', '100.0', '3336.', '17.0', '74', 'US']\n",
      "['Datsun B210', '31.0', '4', '79.00', '67.00', '1950.', '19.0', '74', 'Japan']\n",
      "['Ford Pinto', '26.0', '4', '122.0', '80.00', '2451.', '16.5', '74', 'US']\n",
      "['Toyota Corolla 1200', '32.0', '4', '71.00', '65.00', '1836.', '21.0', '74', 'Japan']\n",
      "['Chevrolet Vega', '25.0', '4', '140.0', '75.00', '2542.', '17.0', '74', 'US']\n",
      "['Chevrolet Chevelle Malibu Classic', '16.0', '6', '250.0', '100.0', '3781.', '17.0', '74', 'US']\n",
      "['AMC Matador', '16.0', '6', '258.0', '110.0', '3632.', '18.0', '74', 'US']\n",
      "['Plymouth Satellite Sebring', '18.0', '6', '225.0', '105.0', '3613.', '16.5', '74', 'US']\n",
      "['Ford Gran Torino', '16.0', '8', '302.0', '140.0', '4141.', '14.0', '74', 'US']\n",
      "['Buick Century Luxus (sw)', '13.0', '8', '350.0', '150.0', '4699.', '14.5', '74', 'US']\n",
      "['Dodge Coronet Custom (sw)', '14.0', '8', '318.0', '150.0', '4457.', '13.5', '74', 'US']\n",
      "['Ford Gran Torino (sw)', '14.0', '8', '302.0', '140.0', '4638.', '16.0', '74', 'US']\n",
      "['AMC Matador (sw)', '14.0', '8', '304.0', '150.0', '4257.', '15.5', '74', 'US']\n",
      "['Audi Fox', '29.0', '4', '98.00', '83.00', '2219.', '16.5', '74', 'Europe']\n",
      "['Volkswagen Dasher', '26.0', '4', '79.00', '67.00', '1963.', '15.5', '74', 'Europe']\n",
      "['Opel Manta', '26.0', '4', '97.00', '78.00', '2300.', '14.5', '74', 'Europe']\n",
      "['Toyota Corolla', '31.0', '4', '76.00', '52.00', '1649.', '16.5', '74', 'Japan']\n",
      "['Datsun 710', '32.0', '4', '83.00', '61.00', '2003.', '19.0', '74', 'Japan']\n",
      "['Dodge Colt', '28.0', '4', '90.00', '75.00', '2125.', '14.5', '74', 'US']\n",
      "['Fiat 128', '24.0', '4', '90.00', '75.00', '2108.', '15.5', '74', 'Europe']\n",
      "['Fiat 124 TC', '26.0', '4', '116.0', '75.00', '2246.', '14.0', '74', 'Europe']\n",
      "['Honda Civic', '24.0', '4', '120.0', '97.00', '2489.', '15.0', '74', 'Japan']\n",
      "['Subaru', '26.0', '4', '108.0', '93.00', '2391.', '15.5', '74', 'Japan']\n",
      "['Fiat x1.9', '31.0', '4', '79.00', '67.00', '2000.', '16.0', '74', 'Europe']\n",
      "['Plymouth Valiant Custom', '19.0', '6', '225.0', '95.00', '3264.', '16.0', '75', 'US']\n",
      "['Chevrolet Nova', '18.0', '6', '250.0', '105.0', '3459.', '16.0', '75', 'US']\n",
      "['Mercury Monarch', '15.0', '6', '250.0', '72.00', '3432.', '21.0', '75', 'US']\n",
      "['Ford Maverick', '15.0', '6', '250.0', '72.00', '3158.', '19.5', '75', 'US']\n",
      "['Pontiac Catalina', '16.0', '8', '400.0', '170.0', '4668.', '11.5', '75', 'US']\n",
      "['Chevrolet Bel Air', '15.0', '8', '350.0', '145.0', '4440.', '14.0', '75', 'US']\n",
      "['Plymouth Grand Fury', '16.0', '8', '318.0', '150.0', '4498.', '14.5', '75', 'US']\n",
      "['Ford LTD', '14.0', '8', '351.0', '148.0', '4657.', '13.5', '75', 'US']\n",
      "['Buick Century', '17.0', '6', '231.0', '110.0', '3907.', '21.0', '75', 'US']\n",
      "['Chevrolete Chevelle Malibu', '16.0', '6', '250.0', '105.0', '3897.', '18.5', '75', 'US']\n",
      "['AMC Matador', '15.0', '6', '258.0', '110.0', '3730.', '19.0', '75', 'US']\n",
      "['Plymouth Fury', '18.0', '6', '225.0', '95.00', '3785.', '19.0', '75', 'US']\n",
      "['Buick Skyhawk', '21.0', '6', '231.0', '110.0', '3039.', '15.0', '75', 'US']\n",
      "['Chevrolet Monza 2+2', '20.0', '8', '262.0', '110.0', '3221.', '13.5', '75', 'US']\n",
      "['Ford Mustang II', '13.0', '8', '302.0', '129.0', '3169.', '12.0', '75', 'US']\n",
      "['Toyota Corolla', '29.0', '4', '97.00', '75.00', '2171.', '16.0', '75', 'Japan']\n",
      "['Ford Pinto', '23.0', '4', '140.0', '83.00', '2639.', '17.0', '75', 'US']\n",
      "['AMC Gremlin', '20.0', '6', '232.0', '100.0', '2914.', '16.0', '75', 'US']\n",
      "['Pontiac Astro', '23.0', '4', '140.0', '78.00', '2592.', '18.5', '75', 'US']\n",
      "['Toyota Corolla', '24.0', '4', '134.0', '96.00', '2702.', '13.5', '75', 'Japan']\n",
      "['Volkswagen Dasher', '25.0', '4', '90.00', '71.00', '2223.', '16.5', '75', 'Europe']\n",
      "['Datsun 710', '24.0', '4', '119.0', '97.00', '2545.', '17.0', '75', 'Japan']\n",
      "['Ford Pinto', '18.0', '6', '171.0', '97.00', '2984.', '14.5', '75', 'US']\n",
      "['Volkswagen Rabbit', '29.0', '4', '90.00', '70.00', '1937.', '14.0', '75', 'Europe']\n",
      "['AMC Pacer', '19.0', '6', '232.0', '90.00', '3211.', '17.0', '75', 'US']\n",
      "['Audi 100LS', '23.0', '4', '115.0', '95.00', '2694.', '15.0', '75', 'Europe']\n",
      "['Peugeot 504', '23.0', '4', '120.0', '88.00', '2957.', '17.0', '75', 'Europe']\n",
      "['Volvo 244DL', '22.0', '4', '121.0', '98.00', '2945.', '14.5', '75', 'Europe']\n",
      "['Saab 99LE', '25.0', '4', '121.0', '115.0', '2671.', '13.5', '75', 'Europe']\n",
      "['Honda Civic CVCC', '33.0', '4', '91.00', '53.00', '1795.', '17.5', '75', 'Japan']\n",
      "['Fiat 131', '28.0', '4', '107.0', '86.00', '2464.', '15.5', '76', 'Europe']\n",
      "['Opel 1900', '25.0', '4', '116.0', '81.00', '2220.', '16.9', '76', 'Europe']\n",
      "['Capri ii', '25.0', '4', '140.0', '92.00', '2572.', '14.9', '76', 'US']\n",
      "['Dodge Colt', '26.0', '4', '98.00', '79.00', '2255.', '17.7', '76', 'US']\n",
      "['Renault 12tl', '27.0', '4', '101.0', '83.00', '2202.', '15.3', '76', 'Europe']\n",
      "['Chevrolet Chevelle Malibu Classic', '17.5', '8', '305.0', '140.0', '4215.', '13.0', '76', 'US']\n",
      "['Dodge Coronet Brougham', '16.0', '8', '318.0', '150.0', '4190.', '13.0', '76', 'US']\n",
      "['AMC Matador', '15.5', '8', '304.0', '120.0', '3962.', '13.9', '76', 'US']\n",
      "['Ford Gran Torino', '14.5', '8', '351.0', '152.0', '4215.', '12.8', '76', 'US']\n",
      "['Plymouth Valiant', '22.0', '6', '225.0', '100.0', '3233.', '15.4', '76', 'US']\n",
      "['Chevrolet Nova', '22.0', '6', '250.0', '105.0', '3353.', '14.5', '76', 'US']\n",
      "['Ford Maverick', '24.0', '6', '200.0', '81.00', '3012.', '17.6', '76', 'US']\n",
      "['AMC Hornet', '22.5', '6', '232.0', '90.00', '3085.', '17.6', '76', 'US']\n",
      "['Chevrolet Chevette', '29.0', '4', '85.00', '52.00', '2035.', '22.2', '76', 'US']\n",
      "['Chevrolet Woody', '24.5', '4', '98.00', '60.00', '2164.', '22.1', '76', 'US']\n",
      "['Volkswagen Rabbit', '29.0', '4', '90.00', '70.00', '1937.', '14.2', '76', 'Europe']\n",
      "['Honda Civic', '33.0', '4', '91.00', '53.00', '1795.', '17.4', '76', 'Japan']\n",
      "['Dodge Aspen SE', '20.0', '6', '225.0', '100.0', '3651.', '17.7', '76', 'US']\n",
      "['Ford Grenada ghia', '18.0', '6', '250.0', '78.00', '3574.', '21.0', '76', 'US']\n",
      "['Pontiac Ventura SJ', '18.5', '6', '250.0', '110.0', '3645.', '16.2', '76', 'US']\n",
      "['AMC Pacer d/l', '17.5', '6', '258.0', '95.00', '3193.', '17.8', '76', 'US']\n",
      "['Volkswagen Rabbit', '29.5', '4', '97.00', '71.00', '1825.', '12.2', '76', 'Europe']\n",
      "['Datsun B-210', '32.0', '4', '85.00', '70.00', '1990.', '17.0', '76', 'Japan']\n",
      "['Toyota Corolla', '28.0', '4', '97.00', '75.00', '2155.', '16.4', '76', 'Japan']\n",
      "['Ford Pinto', '26.5', '4', '140.0', '72.00', '2565.', '13.6', '76', 'US']\n",
      "['Volvo 245', '20.0', '4', '130.0', '102.0', '3150.', '15.7', '76', 'Europe']\n",
      "['Plymouth Volare Premier v8', '13.0', '8', '318.0', '150.0', '3940.', '13.2', '76', 'US']\n",
      "['Peugeot 504', '19.0', '4', '120.0', '88.00', '3270.', '21.9', '76', 'Europe']\n",
      "['Toyota Mark II', '19.0', '6', '156.0', '108.0', '2930.', '15.5', '76', 'Japan']\n",
      "['Mercedes-Benz 280s', '16.5', '6', '168.0', '120.0', '3820.', '16.7', '76', 'Europe']\n",
      "['Cadillac Seville', '16.5', '8', '350.0', '180.0', '4380.', '12.1', '76', 'US']\n",
      "['Chevrolet C10', '13.0', '8', '350.0', '145.0', '4055.', '12.0', '76', 'US']\n",
      "['Ford F108', '13.0', '8', '302.0', '130.0', '3870.', '15.0', '76', 'US']\n",
      "['Dodge D100', '13.0', '8', '318.0', '150.0', '3755.', '14.0', '76', 'US']\n",
      "['Honda Accord CVCC', '31.5', '4', '98.00', '68.00', '2045.', '18.5', '77', 'Japan']\n",
      "['Buick Opel Isuzu Deluxe', '30.0', '4', '111.0', '80.00', '2155.', '14.8', '77', 'US']\n",
      "['Renault 5 GTL', '36.0', '4', '79.00', '58.00', '1825.', '18.6', '77', 'Europe']\n",
      "['Plymouth Arrow GS', '25.5', '4', '122.0', '96.00', '2300.', '15.5', '77', 'US']\n",
      "['Datsun F-10 Hatchback', '33.5', '4', '85.00', '70.00', '1945.', '16.8', '77', 'Japan']\n",
      "['Chevrolet Caprice Classic', '17.5', '8', '305.0', '145.0', '3880.', '12.5', '77', 'US']\n",
      "['Oldsmobile Cutlass Supreme', '17.0', '8', '260.0', '110.0', '4060.', '19.0', '77', 'US']\n",
      "['Dodge Monaco Brougham', '15.5', '8', '318.0', '145.0', '4140.', '13.7', '77', 'US']\n",
      "['Mercury Cougar Brougham', '15.0', '8', '302.0', '130.0', '4295.', '14.9', '77', 'US']\n",
      "['Chevrolet Concours', '17.5', '6', '250.0', '110.0', '3520.', '16.4', '77', 'US']\n",
      "['Buick Skylark', '20.5', '6', '231.0', '105.0', '3425.', '16.9', '77', 'US']\n",
      "['Plymouth Volare Custom', '19.0', '6', '225.0', '100.0', '3630.', '17.7', '77', 'US']\n",
      "['Ford Grenada', '18.5', '6', '250.0', '98.00', '3525.', '19.0', '77', 'US']\n",
      "['Pontiac Grand Prix LJ', '16.0', '8', '400.0', '180.0', '4220.', '11.1', '77', 'US']\n",
      "['Chevrolet Monte Carlo Landau', '15.5', '8', '350.0', '170.0', '4165.', '11.4', '77', 'US']\n",
      "['Chrysler Cordoba', '15.5', '8', '400.0', '190.0', '4325.', '12.2', '77', 'US']\n",
      "['Ford Thunderbird', '16.0', '8', '351.0', '149.0', '4335.', '14.5', '77', 'US']\n",
      "['Volkswagen Rabbit Custom', '29.0', '4', '97.00', '78.00', '1940.', '14.5', '77', 'Europe']\n",
      "['Pontiac Sunbird Coupe', '24.5', '4', '151.0', '88.00', '2740.', '16.0', '77', 'US']\n",
      "['Toyota Corolla Liftback', '26.0', '4', '97.00', '75.00', '2265.', '18.2', '77', 'Japan']\n",
      "['Ford Mustang II 2+2', '25.5', '4', '140.0', '89.00', '2755.', '15.8', '77', 'US']\n",
      "['Chevrolet Chevette', '30.5', '4', '98.00', '63.00', '2051.', '17.0', '77', 'US']\n",
      "['Dodge Colt m/m', '33.5', '4', '98.00', '83.00', '2075.', '15.9', '77', 'US']\n",
      "['Subaru DL', '30.0', '4', '97.00', '67.00', '1985.', '16.4', '77', 'Japan']\n",
      "['Volkswagen Dasher', '30.5', '4', '97.00', '78.00', '2190.', '14.1', '77', 'Europe']\n",
      "['Datsun 810', '22.0', '6', '146.0', '97.00', '2815.', '14.5', '77', 'Japan']\n",
      "['BMW 320i', '21.5', '4', '121.0', '110.0', '2600.', '12.8', '77', 'Europe']\n",
      "['Mazda RX-4', '21.5', '3', '80.00', '110.0', '2720.', '13.5', '77', 'Japan']\n",
      "['Volkswagen Rabbit Custom Diesel', '43.1', '4', '90.00', '48.00', '1985.', '21.5', '78', 'Europe']\n",
      "['Ford Fiesta', '36.1', '4', '98.00', '66.00', '1800.', '14.4', '78', 'US']\n",
      "['Mazda GLC Deluxe', '32.8', '4', '78.00', '52.00', '1985.', '19.4', '78', 'Japan']\n",
      "['Datsun B210 GX', '39.4', '4', '85.00', '70.00', '2070.', '18.6', '78', 'Japan']\n",
      "['Honda Civic CVCC', '36.1', '4', '91.00', '60.00', '1800.', '16.4', '78', 'Japan']\n",
      "['Oldsmobile Cutlass Salon Brougham', '19.9', '8', '260.0', '110.0', '3365.', '15.5', '78', 'US']\n",
      "['Dodge Diplomat', '19.4', '8', '318.0', '140.0', '3735.', '13.2', '78', 'US']\n",
      "['Mercury Monarch ghia', '20.2', '8', '302.0', '139.0', '3570.', '12.8', '78', 'US']\n",
      "['Pontiac Phoenix LJ', '19.2', '6', '231.0', '105.0', '3535.', '19.2', '78', 'US']\n",
      "['Chevrolet Malibu', '20.5', '6', '200.0', '95.00', '3155.', '18.2', '78', 'US']\n",
      "['Ford Fairmont (auto)', '20.2', '6', '200.0', '85.00', '2965.', '15.8', '78', 'US']\n",
      "['Ford Fairmont (man)', '25.1', '4', '140.0', '88.00', '2720.', '15.4', '78', 'US']\n",
      "['Plymouth Volare', '20.5', '6', '225.0', '100.0', '3430.', '17.2', '78', 'US']\n",
      "['AMC Concord', '19.4', '6', '232.0', '90.00', '3210.', '17.2', '78', 'US']\n",
      "['Buick Century Special', '20.6', '6', '231.0', '105.0', '3380.', '15.8', '78', 'US']\n",
      "['Mercury Zephyr', '20.8', '6', '200.0', '85.00', '3070.', '16.7', '78', 'US']\n",
      "['Dodge Aspen', '18.6', '6', '225.0', '110.0', '3620.', '18.7', '78', 'US']\n",
      "['AMC Concord d/l', '18.1', '6', '258.0', '120.0', '3410.', '15.1', '78', 'US']\n",
      "['Chevrolet Monte Carlo Landau', '19.2', '8', '305.0', '145.0', '3425.', '13.2', '78', 'US']\n",
      "['Buick Regal Sport Coupe (turbo)', '17.7', '6', '231.0', '165.0', '3445.', '13.4', '78', 'US']\n",
      "['Ford Futura', '18.1', '8', '302.0', '139.0', '3205.', '11.2', '78', 'US']\n",
      "['Dodge Magnum XE', '17.5', '8', '318.0', '140.0', '4080.', '13.7', '78', 'US']\n",
      "['Chevrolet Chevette', '30.0', '4', '98.00', '68.00', '2155.', '16.5', '78', 'US']\n",
      "['Toyota Corolla', '27.5', '4', '134.0', '95.00', '2560.', '14.2', '78', 'Japan']\n",
      "['Datsun 510', '27.2', '4', '119.0', '97.00', '2300.', '14.7', '78', 'Japan']\n",
      "['Dodge Omni', '30.9', '4', '105.0', '75.00', '2230.', '14.5', '78', 'US']\n",
      "['Toyota Celica GT Liftback', '21.1', '4', '134.0', '95.00', '2515.', '14.8', '78', 'Japan']\n",
      "['Plymouth Sapporo', '23.2', '4', '156.0', '105.0', '2745.', '16.7', '78', 'US']\n",
      "['Oldsmobile Starfire SX', '23.8', '4', '151.0', '85.00', '2855.', '17.6', '78', 'US']\n",
      "['Datsun 200-SX', '23.9', '4', '119.0', '97.00', '2405.', '14.9', '78', 'Japan']\n",
      "['Audi 5000', '20.3', '5', '131.0', '103.0', '2830.', '15.9', '78', 'Europe']\n",
      "['Volvo 264gl', '17.0', '6', '163.0', '125.0', '3140.', '13.6', '78', 'Europe']\n",
      "['Saab 99gle', '21.6', '4', '121.0', '115.0', '2795.', '15.7', '78', 'Europe']\n",
      "['Peugeot 604sl', '16.2', '6', '163.0', '133.0', '3410.', '15.8', '78', 'Europe']\n",
      "['Volkswagen Scirocco', '31.5', '4', '89.00', '71.00', '1990.', '14.9', '78', 'Europe']\n",
      "['Honda Accord LX', '29.5', '4', '98.00', '68.00', '2135.', '16.6', '78', 'Japan']\n",
      "['Pontiac Lemans V6', '21.5', '6', '231.0', '115.0', '3245.', '15.4', '79', 'US']\n",
      "['Mercury Zephyr 6', '19.8', '6', '200.0', '85.00', '2990.', '18.2', '79', 'US']\n",
      "['Ford Fairmont 4', '22.3', '4', '140.0', '88.00', '2890.', '17.3', '79', 'US']\n",
      "['AMC Concord DL 6', '20.2', '6', '232.0', '90.00', '3265.', '18.2', '79', 'US']\n",
      "['Dodge Aspen 6', '20.6', '6', '225.0', '110.0', '3360.', '16.6', '79', 'US']\n",
      "['Chevrolet Caprice Classic', '17.0', '8', '305.0', '130.0', '3840.', '15.4', '79', 'US']\n",
      "['Ford LTD Landau', '17.6', '8', '302.0', '129.0', '3725.', '13.4', '79', 'US']\n",
      "['Mercury Grand Marquis', '16.5', '8', '351.0', '138.0', '3955.', '13.2', '79', 'US']\n",
      "['Dodge St. Regis', '18.2', '8', '318.0', '135.0', '3830.', '15.2', '79', 'US']\n",
      "['Buick Estate Wagon (sw)', '16.9', '8', '350.0', '155.0', '4360.', '14.9', '79', 'US']\n",
      "['Ford Country Squire (sw)', '15.5', '8', '351.0', '142.0', '4054.', '14.3', '79', 'US']\n",
      "['Chevrolet Malibu Classic (sw)', '19.2', '8', '267.0', '125.0', '3605.', '15.0', '79', 'US']\n",
      "['Chrysler Lebaron Town @ Country (sw)', '18.5', '8', '360.0', '150.0', '3940.', '13.0', '79', 'US']\n",
      "['Volkswagen Rabbit Custom', '31.9', '4', '89.00', '71.00', '1925.', '14.0', '79', 'Europe']\n",
      "['Mazda GLC Deluxe', '34.1', '4', '86.00', '65.00', '1975.', '15.2', '79', 'Japan']\n",
      "['Dodge Colt Hatchback Custom', '35.7', '4', '98.00', '80.00', '1915.', '14.4', '79', 'US']\n",
      "['AMC Spirit DL', '27.4', '4', '121.0', '80.00', '2670.', '15.0', '79', 'US']\n",
      "['Mercedes Benz 300d', '25.4', '5', '183.0', '77.00', '3530.', '20.1', '79', 'Europe']\n",
      "['Cadillac Eldorado', '23.0', '8', '350.0', '125.0', '3900.', '17.4', '79', 'US']\n",
      "['Peugeot 504', '27.2', '4', '141.0', '71.00', '3190.', '24.8', '79', 'Europe']\n",
      "['Oldsmobile Cutlass Salon Brougham', '23.9', '8', '260.0', '90.00', '3420.', '22.2', '79', 'US']\n",
      "['Plymouth Horizon', '34.2', '4', '105.0', '70.00', '2200.', '13.2', '79', 'US']\n",
      "['Plymouth Horizon TC3', '34.5', '4', '105.0', '70.00', '2150.', '14.9', '79', 'US']\n",
      "['Datsun 210', '31.8', '4', '85.00', '65.00', '2020.', '19.2', '79', 'Japan']\n",
      "['Fiat Strada Custom', '37.3', '4', '91.00', '69.00', '2130.', '14.7', '79', 'Europe']\n",
      "['Buick Skylark Limited', '28.4', '4', '151.0', '90.00', '2670.', '16.0', '79', 'US']\n",
      "['Chevrolet Citation', '28.8', '6', '173.0', '115.0', '2595.', '11.3', '79', 'US']\n",
      "['Oldsmobile Omega Brougham', '26.8', '6', '173.0', '115.0', '2700.', '12.9', '79', 'US']\n",
      "['Pontiac Phoenix', '33.5', '4', '151.0', '90.00', '2556.', '13.2', '79', 'US']\n",
      "['Volkswagen Rabbit', '41.5', '4', '98.00', '76.00', '2144.', '14.7', '80', 'Europe']\n",
      "['Toyota Corolla Tercel', '38.1', '4', '89.00', '60.00', '1968.', '18.8', '80', 'Japan']\n",
      "['Chevrolet Chevette', '32.1', '4', '98.00', '70.00', '2120.', '15.5', '80', 'US']\n",
      "['Datsun 310', '37.2', '4', '86.00', '65.00', '2019.', '16.4', '80', 'Japan']\n",
      "['Chevrolet Citation', '28.0', '4', '151.0', '90.00', '2678.', '16.5', '80', 'US']\n",
      "['Ford Fairmont', '26.4', '4', '140.0', '88.00', '2870.', '18.1', '80', 'US']\n",
      "['AMC Concord', '24.3', '4', '151.0', '90.00', '3003.', '20.1', '80', 'US']\n",
      "['Dodge Aspen', '19.1', '6', '225.0', '90.00', '3381.', '18.7', '80', 'US']\n",
      "['Audi 4000', '34.3', '4', '97.00', '78.00', '2188.', '15.8', '80', 'Europe']\n",
      "['Toyota Corolla Liftback', '29.8', '4', '134.0', '90.00', '2711.', '15.5', '80', 'Japan']\n",
      "['Mazda 626', '31.3', '4', '120.0', '75.00', '2542.', '17.5', '80', 'Japan']\n",
      "['Datsun 510 Hatchback', '37.0', '4', '119.0', '92.00', '2434.', '15.0', '80', 'Japan']\n",
      "['Toyota Corolla', '32.2', '4', '108.0', '75.00', '2265.', '15.2', '80', 'Japan']\n",
      "['Mazda GLC', '46.6', '4', '86.00', '65.00', '2110.', '17.9', '80', 'Japan']\n",
      "['Dodge Colt', '27.9', '4', '156.0', '105.0', '2800.', '14.4', '80', 'US']\n",
      "['Datsun 210', '40.8', '4', '85.00', '65.00', '2110.', '19.2', '80', 'Japan']\n",
      "['Volkswagen Rabbit C (Diesel)', '44.3', '4', '90.00', '48.00', '2085.', '21.7', '80', 'Europe']\n",
      "['Volkswagen Dasher (diesel)', '43.4', '4', '90.00', '48.00', '2335.', '23.7', '80', 'Europe']\n",
      "['Audi 5000s (diesel)', '36.4', '5', '121.0', '67.00', '2950.', '19.9', '80', 'Europe']\n",
      "['Mercedes-Benz 240d', '30.0', '4', '146.0', '67.00', '3250.', '21.8', '80', 'Europe']\n",
      "['Honda Civic 1500 gl', '44.6', '4', '91.00', '67.00', '1850.', '13.8', '80', 'Japan']\n",
      "['Renault Lecar Deluxe', '40.9', '4', '85.00', '0', '1835.', '17.3', '80', 'Europe']\n",
      "['Subaru DL', '33.8', '4', '97.00', '67.00', '2145.', '18.0', '80', 'Japan']\n",
      "['Volkswagen Rabbit', '29.8', '4', '89.00', '62.00', '1845.', '15.3', '80', 'Europe']\n",
      "['Datsun 280-ZX', '32.7', '6', '168.0', '132.0', '2910.', '11.4', '80', 'Japan']\n",
      "['Mazda RX-7 GS', '23.7', '3', '70.00', '100.0', '2420.', '12.5', '80', 'Japan']\n",
      "['Triumph TR7 Coupe', '35.0', '4', '122.0', '88.00', '2500.', '15.1', '80', 'Europe']\n",
      "['Ford Mustang Cobra', '23.6', '4', '140.0', '0', '2905.', '14.3', '80', 'US']\n",
      "['Honda Accord', '32.4', '4', '107.0', '72.00', '2290.', '17.0', '80', 'Japan']\n",
      "['Plymouth Reliant', '27.2', '4', '135.0', '84.00', '2490.', '15.7', '81', 'US']\n",
      "['Buick Skylark', '26.6', '4', '151.0', '84.00', '2635.', '16.4', '81', 'US']\n",
      "['Dodge Aries Wagon (sw)', '25.8', '4', '156.0', '92.00', '2620.', '14.4', '81', 'US']\n",
      "['Chevrolet Citation', '23.5', '6', '173.0', '110.0', '2725.', '12.6', '81', 'US']\n",
      "['Plymouth Reliant', '30.0', '4', '135.0', '84.00', '2385.', '12.9', '81', 'US']\n",
      "['Toyota Starlet', '39.1', '4', '79.00', '58.00', '1755.', '16.9', '81', 'Japan']\n",
      "['Plymouth Champ', '39.0', '4', '86.00', '64.00', '1875.', '16.4', '81', 'US']\n",
      "['Honda Civic 1300', '35.1', '4', '81.00', '60.00', '1760.', '16.1', '81', 'Japan']\n",
      "['Subaru', '32.3', '4', '97.00', '67.00', '2065.', '17.8', '81', 'Japan']\n",
      "['Datsun 210 MPG', '37.0', '4', '85.00', '65.00', '1975.', '19.4', '81', 'Japan']\n",
      "['Toyota Tercel', '37.7', '4', '89.00', '62.00', '2050.', '17.3', '81', 'Japan']\n",
      "['Mazda GLC 4', '34.1', '4', '91.00', '68.00', '1985.', '16.0', '81', 'Japan']\n",
      "['Plymouth Horizon 4', '34.7', '4', '105.0', '63.00', '2215.', '14.9', '81', 'US']\n",
      "['Ford Escort 4W', '34.4', '4', '98.00', '65.00', '2045.', '16.2', '81', 'US']\n",
      "['Ford Escort 2H', '29.9', '4', '98.00', '65.00', '2380.', '20.7', '81', 'US']\n",
      "['Volkswagen Jetta', '33.0', '4', '105.0', '74.00', '2190.', '14.2', '81', 'Europe']\n",
      "['Renault 18i', '34.5', '4', '100.0', '0', '2320.', '15.8', '81', 'Europe']\n",
      "['Honda Prelude', '33.7', '4', '107.0', '75.00', '2210.', '14.4', '81', 'Japan']\n",
      "['Toyota Corolla', '32.4', '4', '108.0', '75.00', '2350.', '16.8', '81', 'Japan']\n",
      "['Datsun 200SX', '32.9', '4', '119.0', '100.0', '2615.', '14.8', '81', 'Japan']\n",
      "['Mazda 626', '31.6', '4', '120.0', '74.00', '2635.', '18.3', '81', 'Japan']\n",
      "['Peugeot 505s Turbo Diesel', '28.1', '4', '141.0', '80.00', '3230.', '20.4', '81', 'Europe']\n",
      "['Saab 900s', '0', '4', '121.0', '110.0', '2800.', '15.4', '81', 'Europe']\n",
      "['Volvo Diesel', '30.7', '6', '145.0', '76.00', '3160.', '19.6', '81', 'Europe']\n",
      "['Toyota Cressida', '25.4', '6', '168.0', '116.0', '2900.', '12.6', '81', 'Japan']\n",
      "['Datsun 810 Maxima', '24.2', '6', '146.0', '120.0', '2930.', '13.8', '81', 'Japan']\n",
      "['Buick Century', '22.4', '6', '231.0', '110.0', '3415.', '15.8', '81', 'US']\n",
      "['Oldsmobile Cutlass LS', '26.6', '8', '350.0', '105.0', '3725.', '19.0', '81', 'US']\n",
      "['Ford Grenada gl', '20.2', '6', '200.0', '88.00', '3060.', '17.1', '81', 'US']\n",
      "['Chrysler Lebaron Salon', '17.6', '6', '225.0', '85.00', '3465.', '16.6', '81', 'US']\n",
      "['Chevrolet Cavalier', '28.0', '4', '112.0', '88.00', '2605.', '19.6', '82', 'US']\n",
      "['Chevrolet Cavalier Wagon', '27.0', '4', '112.0', '88.00', '2640.', '18.6', '82', 'US']\n",
      "['Chevrolet Cavalier 2-door', '34.0', '4', '112.0', '88.00', '2395.', '18.0', '82', 'US']\n",
      "['Pontiac J2000 SE Hatchback', '31.0', '4', '112.0', '85.00', '2575.', '16.2', '82', 'US']\n",
      "['Dodge Aries SE', '29.0', '4', '135.0', '84.00', '2525.', '16.0', '82', 'US']\n",
      "['Pontiac Phoenix', '27.0', '4', '151.0', '90.00', '2735.', '18.0', '82', 'US']\n",
      "['Ford Fairmont Futura', '24.0', '4', '140.0', '92.00', '2865.', '16.4', '82', 'US']\n",
      "['AMC Concord DL', '23.0', '4', '151.0', '0', '3035.', '20.5', '82', 'US']\n",
      "['Volkswagen Rabbit l', '36.0', '4', '105.0', '74.00', '1980.', '15.3', '82', 'Europe']\n",
      "['Mazda GLC Custom l', '37.0', '4', '91.00', '68.00', '2025.', '18.2', '82', 'Japan']\n",
      "['Mazda GLC Custom', '31.0', '4', '91.00', '68.00', '1970.', '17.6', '82', 'Japan']\n",
      "['Plymouth Horizon Miser', '38.0', '4', '105.0', '63.00', '2125.', '14.7', '82', 'US']\n",
      "['Mercury Lynx l', '36.0', '4', '98.00', '70.00', '2125.', '17.3', '82', 'US']\n",
      "['Nissan Stanza XE', '36.0', '4', '120.0', '88.00', '2160.', '14.5', '82', 'Japan']\n",
      "['Honda Accord', '36.0', '4', '107.0', '75.00', '2205.', '14.5', '82', 'Japan']\n",
      "['Toyota Corolla', '34.0', '4', '108.0', '70.00', '2245', '16.9', '82', 'Japan']\n",
      "['Honda Civic', '38.0', '4', '91.00', '67.00', '1965.', '15.0', '82', 'Japan']\n",
      "['Honda Civic (auto)', '32.0', '4', '91.00', '67.00', '1965.', '15.7', '82', 'Japan']\n",
      "['Datsun 310 GX', '38.0', '4', '91.00', '67.00', '1995.', '16.2', '82', 'Japan']\n",
      "['Buick Century Limited', '25.0', '6', '181.0', '110.0', '2945.', '16.4', '82', 'US']\n",
      "['Oldsmobile Cutlass Ciera (diesel)', '38.0', '6', '262.0', '85.00', '3015.', '17.0', '82', 'US']\n",
      "['Chrysler Lebaron Medallion', '26.0', '4', '156.0', '92.00', '2585.', '14.5', '82', 'US']\n",
      "['Ford Grenada l', '22.0', '6', '232.0', '112.0', '2835', '14.7', '82', 'US']\n",
      "['Toyota Celica GT', '32.0', '4', '144.0', '96.00', '2665.', '13.9', '82', 'Japan']\n",
      "['Dodge Charger 2.2', '36.0', '4', '135.0', '84.00', '2370.', '13.0', '82', 'US']\n",
      "['Chevrolet Camaro', '27.0', '4', '151.0', '90.00', '2950.', '17.3', '82', 'US']\n",
      "['Ford Mustang GL', '27.0', '4', '140.0', '86.00', '2790.', '15.6', '82', 'US']\n",
      "['Volkswagen Pickup', '44.0', '4', '97.00', '52.00', '2130.', '24.6', '82', 'Europe']\n",
      "['Dodge Rampage', '32.0', '4', '135.0', '84.00', '2295.', '11.6', '82', 'US']\n",
      "['Ford Ranger', '28.0', '4', '120.0', '79.00', '2625.', '18.6', '82', 'US']\n",
      "['Chevy S-10', '31.0', '4', '119.0', '82.00', '2720.', '19.4', '82', 'US']\n"
     ]
    }
   ],
   "source": [
    "with open('cars.csv') as file:\n",
    "    row_index = 0\n",
    "    for line in file:\n",
    "        if row_index == 0:\n",
    "            # header row\n",
    "            headers = line.strip('\\n').split(';')\n",
    "            print(headers)\n",
    "        elif row_index == 1:\n",
    "            # data type row\n",
    "            data_types = line.strip('\\n').split(';')\n",
    "            print(data_types)\n",
    "        else:\n",
    "            # data rows\n",
    "            data = line.strip('\\n').split(';')\n",
    "            print(data)\n",
    "        row_index += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['STRING', 'DOUBLE', 'INT', 'DOUBLE', 'DOUBLE', 'DOUBLE', 'DOUBLE', 'INT', 'CAT']\n"
     ]
    }
   ],
   "source": [
    "from collections import namedtuple\n",
    "cars = []\n",
    "\n",
    "with open('cars.csv') as file:\n",
    "    row_index = 0\n",
    "    for line in file:\n",
    "        if row_index == 0:\n",
    "            # header row\n",
    "            headers = line.strip('\\n').split(';')\n",
    "            Car = namedtuple('Car', headers)\n",
    "        elif row_index == 1:\n",
    "            # data type row\n",
    "            data_types = line.strip('\\n').split(';')\n",
    "            print(data_types)\n",
    "        else:\n",
    "            # data rows\n",
    "            data = line.strip('\\n').split(';')\n",
    "            car = Car(*data)\n",
    "            cars.append(car)\n",
    "        row_index += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Car(Car='Chevrolet Chevelle Malibu', MPG='18.0', Cylinders='8', Displacement='307.0', Horsepower='130.0', Weight='3504.', Acceleration='12.0', Model='70', Origin='US')\n"
     ]
    }
   ],
   "source": [
    "print(cars[0])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We still need to parse the data into strings, integers, floats..."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's break this problem down into smaller chunks:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "First we need to figure cast to a data type based on the data type string:\n",
    "* STRING --> `str`\n",
    "* DOUBLE --> `float`\n",
    "* INT --> `int`\n",
    "* CAT --> `str`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def cast(data_type, value):\n",
    "    if data_type == 'DOUBLE':\n",
    "        return float(value)\n",
    "    elif data_type == 'INT':\n",
    "        return int(value)\n",
    "    else:\n",
    "        return str(value)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Next we somehow have to cast all the items in a list, based on their corresponding data type in the data_types array:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "data_types = ['STRING', 'DOUBLE', 'INT', 'DOUBLE', 'DOUBLE', 'DOUBLE', 'DOUBLE', 'INT', 'CAT']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "data_row = ['Chevrolet Chevelle Malibu', '18.0', '8', '307.0', '130.0', '3504.', '12.0', '70', 'US']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For something like this, we can just zip up the two lists:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('STRING', 'Chevrolet Chevelle Malibu'),\n",
       " ('DOUBLE', '18.0'),\n",
       " ('INT', '8'),\n",
       " ('DOUBLE', '307.0'),\n",
       " ('DOUBLE', '130.0'),\n",
       " ('DOUBLE', '3504.'),\n",
       " ('DOUBLE', '12.0'),\n",
       " ('INT', '70'),\n",
       " ('CAT', 'US')]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(zip(data_types, data_row))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And we can either use a `map()` or a list comprehension to apply the cast function to each one:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Chevrolet Chevelle Malibu', 18.0, 8, 307.0, 130.0, 3504.0, 12.0, 70, 'US']"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[cast(data_type, value) for data_type, value in zip(data_types, data_row)]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "So now we can write this in a function:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def cast_row(data_types, data_row):\n",
    "    return [cast(data_type, value) \n",
    "            for data_type, value in zip(data_types, data_row)]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's go back and fix up our original code now:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from collections import namedtuple\n",
    "cars = []\n",
    "\n",
    "with open('cars.csv') as file:\n",
    "    row_index = 0\n",
    "    for line in file:\n",
    "        if row_index == 0:\n",
    "            # header row\n",
    "            headers = line.strip('\\n').split(';')\n",
    "            Car = namedtuple('Car', headers)\n",
    "        elif row_index == 1:\n",
    "            # data type row\n",
    "            data_types = line.strip('\\n').split(';')\n",
    "        else:\n",
    "            # data rows\n",
    "            data = line.strip('\\n').split(';')\n",
    "            data = cast_row(data_types, data)\n",
    "            car = Car(*data)\n",
    "            cars.append(car)\n",
    "        row_index += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Car(Car='Chevrolet Chevelle Malibu', MPG=18.0, Cylinders=8, Displacement=307.0, Horsepower=130.0, Weight=3504.0, Acceleration=12.0, Model=70, Origin='US')"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cars[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now let's see if we can clean up this code by using iterators directly:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from collections import namedtuple\n",
    "cars = []\n",
    "\n",
    "with open('cars.csv') as file:\n",
    "    file_iter = iter(file)\n",
    "    headers = next(file_iter).strip('\\n').split(';')\n",
    "    Car = namedtuple('Car', headers)\n",
    "    data_types = next(file_iter).strip('\\n').split(';')\n",
    "    for line in file_iter:\n",
    "        data = line.strip('\\n').split(';')\n",
    "        data = cast_row(data_types, data)\n",
    "        car = Car(*data)\n",
    "        cars.append(car)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Car(Car='Chevrolet Chevelle Malibu', MPG=18.0, Cylinders=8, Displacement=307.0, Horsepower=130.0, Weight=3504.0, Acceleration=12.0, Model=70, Origin='US')"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cars[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "That's already quite a bit cleaner... But why stop there!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from collections import namedtuple\n",
    "\n",
    "with open('cars.csv') as file:\n",
    "    file_iter = iter(file)\n",
    "    headers = next(file_iter).strip('\\n').split(';')\n",
    "    data_types = next(file_iter).strip('\\n').split(';')\n",
    "    cars_data = [cast_row(data_types, \n",
    "                          line.strip('\\n').split(';'))\n",
    "                   for line in file_iter]\n",
    "    cars = [Car(*item) for item in cars_data]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Chevrolet Chevelle Malibu', 18.0, 8, 307.0, 130.0, 3504.0, 12.0, 70, 'US']"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cars_data[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Car(Car='Chevrolet Chevelle Malibu', MPG=18.0, Cylinders=8, Displacement=307.0, Horsepower=130.0, Weight=3504.0, Acceleration=12.0, Model=70, Origin='US')"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cars[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "I chose to split creating the parsed cars_data and the named tuple list into two steps for readability - but we could combine them into a single step:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from collections import namedtuple\n",
    "\n",
    "with open('cars.csv') as file:\n",
    "    file_iter = iter(file)\n",
    "    headers = next(file_iter).strip('\\n').split(';')\n",
    "    data_types = next(file_iter).strip('\\n').split(';')\n",
    "    cars = [Car(*cast_row(data_types, \n",
    "                          line.strip('\\n').split(';')))\n",
    "            for line in file_iter]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Car(Car='Chevrolet Chevelle Malibu', MPG=18.0, Cylinders=8, Displacement=307.0, Horsepower=130.0, Weight=3504.0, Acceleration=12.0, Model=70, Origin='US')"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cars[0]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
